ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select a sheet and return (https://www.excelbanter.com/excel-programming/420088-select-sheet-return.html)

Patrick C. Simonds

Select a sheet and return
 
I need something that will select cell A1 on the sheet named Holiday and
then return me to the sheet that was active when the code was run. It must
go to and select A1 on the Holiday sheet,


Rick Rothstein

Select a sheet and return
 
This macro will do what you asked...

Sub SelectA1OnHolidaySheet()
Dim WS As Worksheet
Set WS = ActiveSheet
On Error GoTo CleanUp
Application.ScreenUpdating = False
Worksheets("Holiday").Activate
Worksheets("Holiday").Range("A1").Select
WS.Activate
CleanUp:
Application.ScreenUpdating = True
End Sub

But I am curious... why do you think you need to do this?

--
Rick (MVP - Excel)


"Patrick C. Simonds" wrote in message
...
I need something that will select cell A1 on the sheet named Holiday and
then return me to the sheet that was active when the code was run. It must
go to and select A1 on the Holiday sheet,



The Code Cage Team[_104_]

Select a sheet and return
 

Generally you do not need to select a cell or worksheet in order to
manipulate it or retrieve data, selecting can have an adverse effect on
performance when you have large sheets or a lot of data.


--
The Code Cage Team

Regards,
The Code Cage Team
http://www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=30124


Rick Rothstein

Select a sheet and return
 
I know that, which is why I asked the OP the question...

"But I am curious... why do you think you need to do this?"

--
Rick (MVP - Excel)


"The Code Cage Team" wrote in
message ...

Generally you do not need to select a cell or worksheet in order to
manipulate it or retrieve data, selecting can have an adverse effect on
performance when you have large sheets or a lot of data.


--
The Code Cage Team

Regards,
The Code Cage Team
http://www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile:
http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=30124



The Code Cage Team[_106_]

Select a sheet and return
 

Rick, that wasn't aimed at you :)
I think the OP may be using something like:
Sheets("Holidays").Activecell.Value
Which of course serves no purpose or maybe the OP is forcing the select
hoping it may follow a hyperlink there....shots in the dark i know, and
yes it was an odd request.


--
The Code Cage Team

Regards,
The Code Cage Team
http://www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=30124


JLGWhiz

Select a sheet and return
 
Could be the OP was trying to do the select in one line without first
activating the sheet and kept getting an error message. Probably just wanted
to know how to get it to select A1 from another sheet.

"The Code Cage Team" wrote:


Rick, that wasn't aimed at you :)
I think the OP may be using something like:
Sheets("Holidays").Activecell.Value
Which of course serves no purpose or maybe the OP is forcing the select
hoping it may follow a hyperlink there....shots in the dark i know, and
yes it was an odd request.


--
The Code Cage Team

Regards,
The Code Cage Team
http://www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=30124




All times are GMT +1. The time now is 12:08 PM.

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