PDA

View Full Version : VBA Project? Guidance Needed!!



CSharp821
03-05-2012, 05:28 PM
I have a general question and I'm not sure where to begin, literally. Can you please leave any direction at a fairly high level so I have the chance to try to figure it out for myself? Here's my initial plan, but here's the issue! I don't know where to start. Where would I begin with this? Would it be an Excel module? I need some direction guys!!

Let me give you a quick run down of what we're trying to accomplish. We start out with 2-3 customer specific spreadsheets with an account number + [static] file name.xlsx and about 7 generic template excel files where we use the data from the customer specific spreadsheets and save a copy of each of the template files in the customers store folder.

What I'm trying to figure out if VBA is the direction that I need to be going with this or if there is another method that would accomplish the same goal or be more efficient at getting it done. My thinking at this point is open one of the customers files, save the active workbook file path as a string (this would contain the file directory, division, customer number and customer name), split the string of the file path and save the information that I need as variables, open the appropriate template files based on division number, probably run a couple recorded macros then re-save the files using the account number in the appropriate directory. If there's anything else I left out for this to make more sense, please let me know and I'll re-edit the post.

Thank you in advance for any guidance!!:beerchug:

Bob Phillips
03-06-2012, 03:15 AM
VBA is definitely the way to go,it is hosted within Excel so there is no call out to other processes, the object model is readily exposed and so on.

Go for it.

Paul_Hossler
03-06-2012, 08:12 AM
probably run a couple recorded macros


1. The macro recorder is very inefficient and generates very specific code. You will need to edit it and probably generalize it

2. When dealing with a WB macro that opens other WB's, I've always found that it's better (i.e. easier for me to debug) if I Dim workbook varilables and Set them accordingly

3. Also, I prefer to be 'wordy' and not assume what the ActiveWorkbook or ActiveSheet is, whenever I can

wbLoaded.Worksheets ("RawData").Cells(1,2).Value = 12345.67

instead of just

Cells(1,2) = 12345.67


Good luck and when you have questions, feel free to stop back

Paul