Goto sheet based on cell contents macro

dgl_thrawn

New Member
Joined
Jan 19, 2005
Messages
6
I have a workbook with various named sheets (eg AM38-03-037-A) and a contents sheet with a list of these sheets exactly as they appear on the sheet name tab. As these sheets have issue numbers and need to be up-issued occasionally, I'd like to be able to have a macro run for each item that will look up the sheet name in the relevant cell and go to that sheet. At the moment I have to type the sheet name into the macro. I currently have:

Sub Button38_Click()
'
' Button38_Click Macro
' Macro recorded 19/04/01 by David Lawrence
'

'
Sheets("AM38-03-037-A").Select
End Sub

If sheet AM38-03-037-A is up-issued to AM38-03-037-B, I have to manually change it. If that change is already typed into a cell (say A37) on the contents sheet, can I refernce the contents of the cell instead?

I am using Excel 97.

dgl_thrawn
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Do you mean something like this:-

Sub Macro1()

On Error GoTo not_found

Dim change As String
change = Sheets("CONTENTS").Range("a37").Value

Sheets(change).Select
Exit Sub

not_found:
MsgBox "Sheet not found.", vbCritical, "Error"

End Sub

Regards,
PAUL.
 
Upvote 0
I now have a follow-up question.

If the macro button is on cell D37 and I'm looking at the contents of cell A37, is there a way of using the offset property to be able to do the same reference.

I want to be able to copy the contents of the macro to the button on cell D38 and have it automatically reference cell A38.

I assume I'd need to put the 'offset' property in the line:

change = Sheets("CONTENTS").Range("A37").Value

but I don't know where.

dgl_thrawn
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,409
Members
448,959
Latest member
camelliaCase

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top