Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm really sorry I keep posting, I know the only way to learn is to ask,
and I've been thrust into the unhappy position of coding in a language I don't know within a program I don't use much. I know I've posted a few queries here, but now I think I've got my ducks in a row and I can lay it all out. I need to find a workbook with a name and date ("Projections John_2004-05-25") located somewhere on the C drive, the dates I need are for the present week, based on a Monday through Sunday week, and the prior week. I can find a workbook that doesn't have the variable date, but man does that variable thing throw me. I was told to use the dir function to load documents with dates in the name, but I need to specify a range of dates for the current and prior M-Sun week. I've looked through several coding books and it looks like the DateDiff would do what I need, but I can't get the format to work. Once I load the books, I need to read the data from the workbooks into a database (assuming this database should be on an Excel workbook, it would be named "Projection Summary") with row one of the database consisting of cells A2, B4, D4, F4 and row two consisting of cells A1, B5, D5, F5 and so on. I would like to create a For Loop with a 7 slot one-dimensional string array so that if a person is removed or added to the list, I can just adjust the array instead of lots of code. Right now I have coded: dim AEArray(1 To 7) As String dim I As Integer AEArray(1)=John AEArray(2)=Joe AEArray(3)=Jane AEArray(4)=Jean AEArray(5)=Jim AEArray(6)=Jeff AEArray(7)=Joan Here is where I get stuck, right now my broken code reads (so I don't forget what I'm doing): For I = 1 To 7 AEArray(I) Next I I would like the loop to use the names in the array to open documents containing the names of the people along with the date range I specified up top and perform the data gathering operations. I have code from Tom Ogilvy for reading from several workbooks, but I think it will need to be changed. Forgive me here but my forte has been C++ and FORTRAN and to make matters worse I can't afford to buy the programming books I need. My code from Tom is: Dim sh As Worksheet Dim wkbk As Workbook Dim i As Long, sPath As String Dim rng as Range Dim varr as Variant workbooks("Master.xls").Worksheets.Add set sh = Activesheet sPath = "C:\Myfolder\Myfiles\" varr = Array("bk1.xls", "bk2.xls",...,"bk7.xls") for i = Ibound(varr) to ubound(varr) set wkbk = workbooks.open(sPath & varr(i)) set rng = sh.Cells(rows.count,1).End(xlup)(2) wkbk.Worksheets(1).Range("A1").Currentregion.Copy_ Destination := rng wkbk.close Savechanges := False Next Now my understanding of this code, while I don't understand what each action is (like where did "xlup" come from and what does it do), I do know that this code should create a master worksheet that reads from the 7 other worksheets and that the data from one week could be kept for the following week. I also would need to create a PivotTable from the data. Now, that seems straight forward enough, but any insight into possible hiccups would be great. Finally, I do know, and have working code, to save this workbook with the current date added to the end. However, how can I prevent someone from using Excel's save button and overwriting what I have? Does making it a template take care of that for me? And can I make the date the Monday of the current week instead of the day that the projection summation was performed? Thanks for any help you can provide me. Again I'm terribly sorry to be a bother and ask all these questions. Jason *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How many 'unique' customers has everyone been involved with? | Excel Discussion (Misc queries) | |||
How many 'unique' customers has everyone been involved with? | Excel Worksheet Functions | |||
Percentage with a zero involved | Excel Discussion (Misc queries) | |||
Matching when spaces are involved | Excel Worksheet Functions | |||
VBA code to perform summation and product summation | Excel Programming |