Results 1 to 6 of 6

Open workbooks with variables in filename using loop

Threaded View

as1234 Open workbooks with variables... 05-31-2011, 11:25 AM
Mordred Re: Open workbooks with... 05-31-2011, 11:28 AM
as1234 Re: Open workbooks with... 05-31-2011, 11:34 AM
Mordred Re: Open workbooks with... 05-31-2011, 12:21 PM
as1234 Re: Open workbooks with... 05-31-2011, 01:08 PM
Mordred Re: Open workbooks with... 05-31-2011, 01:17 PM
  1. #1
    Registered User
    Join Date
    05-31-2011
    Location
    NJ
    MS-Off Ver
    Excel 2010
    Posts
    3

    Open workbooks with variables in filename using loop

    I am trying to open several workbooks with variable names using a loop. All of the filenames are of the form "variable GSC 2011_04.xlsx"

    My code is below, with the problem area highlighted.

    Dim p1, p2, p3, p4
    p1 = "apples01"
    p2 = "bananas2"
    p3 = "cat01"
    p4 = "dog01"
    
    Dim MyPath
    MyPath = "C:\Users\me\Documents\folder"
    ChDir MyPath
    
    Dim x
    For x = 1 to 4
    Workbooks.Open (px & " GSC 2011_04.xlsx")
    Next x
    Thanks!
    Last edited by as1234; 05-31-2011 at 01:10 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1