Creating Code To Populate Information From A Second Workbook With A Variable Name?

xDear

New Member
Joined
Oct 20, 2015
Messages
6
Hello,
I am new to VBA code and have a situation similar to one posted by DonnaJ yesterday</SPAN></SPAN> in her question "Multiple Workbooks - Can You Create Formulas Just Like When Using Mulitple Worksheets?"

Fishboy responded (in part) "...Can you create formulas for multiple workbooks like when using multiple sheets? If you mean you can already write formulas which check different sheets within your current workbook with formulas like this:

=IF(Sheet2!A1="Whatever","Do something","Do something else")

Then yes, this can be expanded to work with separate workBOOKS as well as workSHEETS as follows:

=IF('Other Workbook Name'Sheet2!A1="Whatever","Do something","Do something else")</SPAN>"

I realize these are formulas, not VBA,however,

my question is what if the 'Other Workbook Name' is always different because it is a new report each month-is there a way to grab the name of the newly opened document and assign it to a variable, i.e.,


Dim OWName as String
OWName = 'Other Workbook Name'</SPAN></SPAN>

-so it can then be used as a reference, i.e.,</SPAN></SPAN>

Dim ThisReview as String
ThisReview=[OWName]Sheet1!$B$5 ?


I have found a block of code that prompts the user to select a file from the directory, opens it and then stores the entire file path to a variant named 'FName', but trying to access information from the second workbook using 'FName' does not work either-maybe because of file type mismatch?


Any help would be greatly appreciated since I have now spent the better part of 4 days trying to google an answer.</SPAN></SPAN>
</SPAN></SPAN>
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top