View Single Post
  #1   Report Post  
Dunmarie
 
Posts: n/a
Default Select sheet with VB code

I have a Excel Workbook with a couple of sheets. I would like to call a sheet
depending on a variable selected by the user.
My current code is as follows:
Dim xlw As Excel.Workbook
Dim xls As Excel.Worksheet
Dim xla As Excel.Application

Set xlw = GetObject("G:\Stock Take\Stock Month-End.xls")
Set xls = xlw.ActiveSheet
Set xla = xlw.Parent

[Text44] = xls.Cells(10, 2)
[Text54] = xls.Cells(10, 3)
[Text63] = xls.Cells(10, 4)
[Text201] = xls.Cells(10, 5)
[Text212] = xls.Cells(10, 7)
[Text90] = xls.Cells(10, 8)

The variable is created by then user making a selection from a combo box.
Example:
User select "January" which creates a variable called "varMonth" containing
"Jan" which I would like to use to call a sheet called "Jan" inside the
workbook.
I can create the variable, I would just like to know how to use the variable
to select the sheet.
Any help will be appreciated.
Thanks.