How to evaluate an workbook object by its name in code?

prabha_friend

Board Regular
Joined
Jun 28, 2011
Messages
95
Declaration:
Private wbAcctFees As Workbook

Public Function mac()
Set wbAcctFees = Workbooks.Open(frmPart1.txtAcctFees.Value)
End Function

Formula in a Cell:
=VLOOKUP(A2,INDIRECT("["&GetFileNamefromCode("wbAcctFees")&".xlsx]gen_rpt'!$A:$K"),11,)

Public Function GetFileNamefromCode(filevariable As String) As String
GetFileNamefromCode = Evaluate(filevariable).Name
End Function

Why its not working? and Whats the solution for this? Thanks in advance.
 
Restating the question doesn't really help. I already said you can't do that directly and suggested alternatives but you keep ignoring them, so I'm leaving you to the posters in the other forum.
 
Upvote 0

Forum statistics

Threads
1,226,797
Messages
6,193,051
Members
453,772
Latest member
aastupin

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