+ Reply to Thread
Results 1 to 3 of 3

Trying to refer to Workbook in VBA, when workbook name is the combination of cells

  1. #1
    Registered User
    Join Date
    07-19-2016
    Location
    Berlin
    MS-Off Ver
    2016
    Posts
    3

    Trying to refer to Workbook in VBA, when workbook name is the combination of cells

    Hey people,

    I would be really happy if somebody could help me with the following problem:

    I have some excel files. The Team file and the Team members files. I am trying to create a macro in The Team File to do the following:

    For every Row in the Team file go to the Team members file find some information and copy them. The Members files are in the same folder and they are named after the people's names. It seams that VBA does not accept the name of the Workbook of every member, since I am trying to add it with cell references of the members names:

    for r = 2 To 240
    workbook ("Filepath" & wb.sh.rng.Cell(r, 2).Value & "_" & wb.sh.rng.Cell(r,3).Value & ".xls").Activate etc.

    Any Ideas how I could make it work?

    I would be grateful for your help.

    Cheers

  2. #2
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Trying to refer to Workbook in VBA, when workbook name is the combination of cells

    Try this code to Open & Close your Team Member files.

    Please Login or Register  to view this content.
    1. Reply to thread and inform if suggestion was helpful or not
    2. Click on the star (=Add Reputation) if you think someone helped you
    3. Mark [SOLVED] to this thread if solution was found. (On Menu "Thread Tools" > "Mark this thread as solved")

  3. #3
    Registered User
    Join Date
    07-19-2016
    Location
    Berlin
    MS-Off Ver
    2016
    Posts
    3

    Re: Trying to refer to Workbook in VBA, when workbook name is the combination of cells

    Thank you so much for your quick and accurate response! You really helped me a lot. And of course I realized what I had been doing wrong..

    i just had to reactivate the main WB before the "lRI = lRI + 1" and it worked perfect.

    Thanks a lot again.

    Regards from Berlin.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Refer to a particular workbook
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-06-2015, 07:20 AM
  2. [SOLVED] Refer to Workbook name using wilcard
    By MaddyG in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 01-08-2014, 05:41 PM
  3. [SOLVED] How to refer to the workbook where the macro when another workbook is open during runtime?
    By jonelamora in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2012, 11:21 PM
  4. how to refer to new workbook
    By aretai in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-06-2010, 07:26 AM

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.6.0 RC 1