View Full Version : VBA
SarahRecking
01-25-2017, 09:09 PM
What expression can be used to refer to the Workbook object whose name is “My Workbook.xlsm”?
YasserKhalil
01-25-2017, 10:58 PM
Hello
If the workbook was open you can refer to it using such lines
Dim wbk As Workbook
wbk=workbooks("My Workbook.xlsm")
p45cal
01-26-2017, 04:26 AM
YasserKhalil, that should be:
Set wbk = Workbooks("My Workbook.xlsm")
It depends....
sub M_snb()
with thisworkbook
end with
end sub
or
sub M_snb()
with activeworkbook
end with
end sub
or
sub M_snb()
with workbooks("My Workbook.xlsm")
end with
end sub
or
sub M_snb()
with workbooks(2)
end with
end sub
or
sub M_snb()
set wb= workbooks(2)
set wb= thisworkbook
set wb= activeworkbook
set wb= workbooks("My workbook.xlsm")
end sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.