Select a sheet and return

P

Patrick C. Simonds

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,
 
R

Rick Rothstein

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?
 
T

The Code Cage Team

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
 
R

Rick Rothstein

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?"
 
T

The Code Cage Team

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
 
J

JLGWhiz

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.
 
Top