#1   Report Post  
Greg B
 
Posts: n/a
Default Look up

I want to have a macro that will look for the corresponding sheet to the
reference in cell "a2"

Is this possible and how is it possible

Thanks

Greg


  #2   Report Post  
R.VENKATARAMAN
 
Posts: n/a
Default

try something like this code(the name of the sheet is in A2 of sheet1)

Worksheets(Worksheets("sheet1").Range("a2").Value) .Activate

-----------------------------------
Greg B wrote in message
...
I want to have a macro that will look for the corresponding sheet to the
reference in cell "a2"

Is this possible and how is it possible

Thanks

Greg




  #3   Report Post  
Peter Jausovec
 
Posts: n/a
Default

Hi Greg,

Try this macro:

Dim ws as Worksheet

For Each ws in ThisWorkbook.Sheets
If (ws.Name = ThisWorkbook.ActiveSheet.Range ("A2") then
' do something here if the worksheet exists
Exit for
end if
Next ws


--
http://blog.jausovec.net


"Greg B" je napisal:

I want to have a macro that will look for the corresponding sheet to the
reference in cell "a2"

Is this possible and how is it possible

Thanks

Greg



  #4   Report Post  
Peter Jausovec
 
Posts: n/a
Default

Nice solutions, but it will break if the sheet name in A2 doesn't exist

--
http://blog.jausovec.net


"R.VENKATARAMAN" je napisal:

try something like this code(the name of the sheet is in A2 of sheet1)

Worksheets(Worksheets("sheet1").Range("a2").Value) .Activate

-----------------------------------
Greg B wrote in message
...
I want to have a macro that will look for the corresponding sheet to the
reference in cell "a2"

Is this possible and how is it possible

Thanks

Greg





  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

You could add bit of error checking:

On error resume next
Worksheets(Worksheets("sheet1").Range("a2").Value) .Activate
if err.number < 0 then
msgbox "That sheet doesn't exist
err.clear
end if
on error goto 0



Peter Jausovec wrote:

Nice solutions, but it will break if the sheet name in A2 doesn't exist

--
http://blog.jausovec.net

"R.VENKATARAMAN" je napisal:

try something like this code(the name of the sheet is in A2 of sheet1)

Worksheets(Worksheets("sheet1").Range("a2").Value) .Activate

-----------------------------------
Greg B wrote in message
...
I want to have a macro that will look for the corresponding sheet to the
reference in cell "a2"

Is this possible and how is it possible

Thanks

Greg






--

Dave Peterson


  #6   Report Post  
Greg B
 
Posts: n/a
Default

Thank you to everyone who have helped me

Greg
"Dave Peterson" wrote in message
...
You could add bit of error checking:

On error resume next
Worksheets(Worksheets("sheet1").Range("a2").Value) .Activate
if err.number < 0 then
msgbox "That sheet doesn't exist
err.clear
end if
on error goto 0



Peter Jausovec wrote:

Nice solutions, but it will break if the sheet name in A2 doesn't exist

--
http://blog.jausovec.net

"R.VENKATARAMAN" je napisal:

try something like this code(the name of the sheet is in A2 of sheet1)

Worksheets(Worksheets("sheet1").Range("a2").Value) .Activate

-----------------------------------
Greg B wrote in message
...
I want to have a macro that will look for the corresponding sheet to

the
reference in cell "a2"

Is this possible and how is it possible

Thanks

Greg






--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"