+ Reply to Thread
Page 3 of 3 FirstFirst 123
Results 31 to 36 of 36

Thread: Macro/VBA needed for opening excel file

  1. #31
    Registered User
    Join Date
    10-24-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Macro/VBA needed for opening excel file

    There would be multiple files in the folder, but each one would be unique, the initial part of the filename, which is put into B8 on the spreadsheet the NR00000008 or NR000000018 would be unique, its just asking to open it with the added extension.

    Are you not able to have a section in the code that says you are looking for NR00000008_##???##_??.xlsx or something like that for the Tubes Recieved section? So it is always goes by whatever is in B8 and adds on 11 characters after?

    It is just the plan is to have a lot of different file names in this spreadsheet, so when using the macro, you can auto-populate say 50 of the tables, opening 50 files manually would take a lot longer...

  2. #32
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,376

    Re: Macro/VBA needed for opening excel file

    Yes, we can automate it that way by putting a wild card after the initial NR...characters.
    Since you say that you would want to auto-populate about 50 tables, i can help you with an additional functionality in the code. We can have a list of the 50 or more files in the macro file somewhere and ask the code to populate cell B8 one by one with the entries in that list, open the file, update the data, do any other required steps and then close the file. Then move to the next file in the list, etc.
    Would this work for you? It will take a lil time for the macro to run, maybe a couple of minutes, but you will have all the steps automated.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #33
    Registered User
    Join Date
    10-24-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Macro/VBA needed for opening excel file

    I don't mind having it the way it is, I'm quite happy with the structure - if we can get it so there is a wildcard after the NR######## characters in the Tubes Recieved filename, that would be great and would be enough for all that I'm needing! - how would we go about doing that?

  4. #34
    Registered User
    Join Date
    10-24-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Macro/VBA needed for opening excel file

    What I meant is that you have helped a lot already - the added functionality would be great, but not essential.

  5. #35
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,376

    Re: Macro/VBA needed for opening excel file

    Use this code -
    'TUBES SENT
        Workbooks.Open SentPath & ThisWorkbook.Worksheets(1).Range("B" & i).Value & ".csv"
    And
    'TUBES RECEIVED
    Workbooks.Open RecPath & ThisWorkbook.Worksheets(1).Range("B" & i).Value & "*.xlsx"
    You just have to put NR00000008 or whatever in Cell b8. For tubes sent, it will take the file as is with .csv extension. For Tubes received, it will add an asterisk after 008 for the remaining characters and the extension will be .xlsx.

    Do let me know if you need the added functionality...will have to make a few code changes.
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  6. #36
    Registered User
    Join Date
    10-24-2011
    Location
    Leeds, England
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Macro/VBA needed for opening excel file

    This works a dream! Thank you very much!

    I think any more functionality would just confuse me when I'm using it! Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0