ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select sheet (https://www.excelbanter.com/excel-programming/279059-select-sheet.html)

Abdul[_4_]

Select sheet
 
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

Chip Pearson

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





All times are GMT +1. The time now is 09:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com