ExcelBanter
(
https://www.excelbanter.com/
)
-
Excel Programming
(
https://www.excelbanter.com/excel-programming/
)
- -
Selecting worksheets
(
https://www.excelbanter.com/excel-programming/430300-re-selecting-worksheets.html
)
Don Guillett
Selecting worksheets
Sub gotbacktooriginalsheet()
mysheet = ActiveSheet.Name
Sheets("Sheet4").Select
MsgBox ActiveSheet.Name
Sheets(mysheet).Select
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Don Guillett" wrote in message news:...
As ALWAYS, post your code for comments and suggestions.
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Jacky D." wrote in message
...
How can I name the activeworsheet in the beginning of a macro so I can
then
get back to that worksheet from another sheet later in the macro? I am
constantly adding sheets to this workbook, so just telling the macro to
select sheet2 just won't work. I've tried Setting the sheet, saying: "Set
mysheet = ActiveSheet" and then trying to select mysheet later in the
macro
(using "Sheets(mysheet).Select") when I want to get back to that sheet,
but I
keep getting a runtime error 13, type mismatch. When I debug, it brings
me to
the code were I am trying to get back to that worksheet. I'm still
learning
this, and taking quite a few lumps. I've pretty much got the macro
running
beautifully, except for the fact that I keep needing to re-select the
sheet I
want to work within. It's a bit clumsy, and I'd like to try to make it
run a
bit smoother.
Any help would be appreciated.
All times are GMT +1. The time now is
01:26 PM
.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com