Results 1 to 11 of 11

Thread: Extracting data from various excel reports using VBA

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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:
    1. for i = 0 to ubound(myarray)
    2.    secondpart = myarray(i)
    3.       ' you can change the variable name from specific (vauxhall) to a generic name [I]overall_status[/I], but it makes no difference
    4.       vauxhall_overall_status = "=" & firstpart & Format(Target + 4, "yyyy-mm-dd") & secondpart
    5.     Range("B2").offset(i,0).Value = vauxhall_overall_status
    6. 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

  2. #2

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    6

    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
  •  



Click Here to Expand Forum to Full Width