Select Sheet Based on Variable Content VBA
Solved
Enito
Posted messages
21
Status
Member
-
Enito Posted messages 21 Status Member -
Enito Posted messages 21 Status Member -
Hello,
I have several sheets in my Excel 2010 workbook. I'm working in VBA.
I have a Variant variable that contains a number, and one of the sheets in the workbook is named after that number, so I would like to be able to select the sheet based on the variable. For example,
Sub Select_Sheet ()
Sheets(TOTO).Select
End Sub
Obviously, TOTO is defined, but I'm always getting the error message that the index does not belong to the selection.
Can someone help me with this?
Thanks in advance!
ENITO!
Configuration: Windows Vista / Firefox 10.0.1
I have several sheets in my Excel 2010 workbook. I'm working in VBA.
I have a Variant variable that contains a number, and one of the sheets in the workbook is named after that number, so I would like to be able to select the sheet based on the variable. For example,
Sub Select_Sheet ()
Sheets(TOTO).Select
End Sub
Obviously, TOTO is defined, but I'm always getting the error message that the index does not belong to the selection.
Can someone help me with this?
Thanks in advance!
ENITO!
Configuration: Windows Vista / Firefox 10.0.1