|
-
Nov 3rd, 2008, 09:37 PM
#1
Re: Extracting data from various excel reports using VBA
first you need to decide how to store the values, so a method to fill the array can be determined, then to loop through the array
vb Code:
for i = 0 to ubound(myarray) secondpart = myarray(i) ' you can change the variable name from specific (vauxhall) to a generic name [I]overall_status[/I], but it makes no difference vauxhall_overall_status = "=" & firstpart & Format(Target + 4, "yyyy-mm-dd") & secondpart Range("B2").offset(i,0).Value = vauxhall_overall_status next
i didn't test this at all, the off set will make each row down the value of i, so the first will be on row 2+0, next row 2 +1, next row 2+2 etc
the array needs to contain a list of all the file names you want to process
you can hardcode an array like
myarray = Array("a", "S", "d", "r")
or read the content of a textfile or other methods, that can be changed without editing the vba code
or you can loop through all the files in a given folder
hth
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 4th, 2008, 05:14 AM
#2
Thread Starter
New Member
Re: Extracting data from various excel reports using VBA
westconn,
thanks for taking the time out to reply to my post.
As a relatively newbie to VBA, could you offer me more help and insight.
How will the array loop through to for example....vauxhall_teamwork, vauxhall_communication, ford_teamwork, ford_communication with vauxhall.xls and ford.xls being seperate excel files?
cheers,
alex
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|