ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Look up (https://www.excelbanter.com/excel-discussion-misc-queries/28924-look-up.html)

Greg B

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



R.VENKATARAMAN

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





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


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




Peter Jausovec

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

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

Greg B

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





All times are GMT +1. The time now is 02:19 AM.

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