QUESTION Return to my last workbsheet - FOR PEOPLE WHO REALLY KNOW EXCEL


Posted by Walter on December 23, 2001 3:30 AM

HI
How i can declare my workbook by a variable in VBA

I Have two workbooks whit many sheets with their names
Wen i change in the combobox some data i jump to another workbook look for somthing and return back to my last worksheet.

AND THE QUESTION IS =:)
1-when I change the workbook how to change to the sheet
I want ( the name is what return my combobox and i have a variable in)

2 How to return back to to the sheet I left before i change
ANY IDEAS



Posted by Juan Pablo G. on December 23, 2001 8:52 AM

Some answers

> How i can declare my workbook by a variable in VBA

At the beginning of your macro put this

Dim TWB as Workbook
Set TWB = ThisWorkbook

> 1-when I change the workbook how to change to the sheet
> I want ( the name is what return my combobox and i have a variable in)

Sheets(ComboBox1).Select

> 2 How to return back to to the sheet I left before i change

At the beggining, put this
Dim TWS as Worksheet
Set TWS = ActiveSheet

and when you want to return (That is, at the end of the macro), put this

TWS.Select

Juan Pablo G.