Thread: Select sheet
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Select sheet

Abdul,

Try something like

Sub SaveLocation(Optional GoBack As Variant = False)
Static TopLeftCell As Range
Static SelectedCells As Range
If GoBack = False Then
Set TopLeftCell = ActiveWindow.VisibleRange(1, 1)
Set SelectedCells = Selection
Else
Application.Goto TopLeftCell
SelectedCells.Select
End If
End Sub

To save the current location, use

SaveLocation

Then, to return to the location, use
SaveLocation GoBack:=True



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com




"Abdul" wrote in message
...
Hi,

I am selecting varous sheets thru a userform combobox
based combobox value. How can I store the sheet name
before loading the userform and return to that sheet when
I close the user form with a close button?

Thanks in advance

Abdul