Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 |
Display Modes | |
|
|