Select sheet

A

Abdul

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
 
C

Chip Pearson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top