Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default A Rather Involved Summation Macro

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How many 'unique' customers has everyone been involved with? Michelle Excel Discussion (Misc queries) 7 September 25th 09 06:14 PM
How many 'unique' customers has everyone been involved with? Michelle Excel Worksheet Functions 6 September 25th 09 06:14 PM
Percentage with a zero involved tankerman Excel Discussion (Misc queries) 8 March 5th 09 09:08 AM
Matching when spaces are involved JaB Excel Worksheet Functions 1 November 15th 05 12:46 PM
VBA code to perform summation and product summation 21MSU[_2_] Excel Programming 4 May 17th 04 07:19 PM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"