Look up

G

Greg B

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
 
P

Peter Jausovec

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
 
D

Dave Peterson

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
 
G

Greg B

Thank you to everyone who have helped me

Greg
Dave Peterson said:
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
 
Top