Show worksheets independently using macro assigned buttons

Delvestio

New Member
Joined
Oct 8, 2024
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Hi all, i'm brand new at this and would like to politely ask you wonderful people if you could spare the time to help me with a problem:

I have one WorkBook.
This WorkBook contains 14 WorkSheets and Summary Sheet.
The Summary Sheet is a constant and always shown.
The WorkSheets are all hidden by default.
Within the Summary Sheet there are cells which contain the names of the WorkSheets, as follows:

Buildings
Contents
Jewellery
Jewellery (Specified)
Art & Antiques
Alternative Accommodation
Preventative Measures
Electricity Calcs

I need to have a button assigned to each cell that when clicked Shows the WorkSheet.

Help me.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
P.S. doesnt have to be a button, could easily be an image or shape (like and arrow) with the macro assigned.
 
Upvote 0
P.S. doesnt have to be a button, could easily be an image or shape (like and arrow) with the macro assigned.
Hi welcome to forum
A shape would be a good choice.
It would be helpful if you are you able to share copy of your summary sheet using MrExcel Addin

Dave
 
Upvote 0
Hi welcome to forum
A shape would be a good choice.
It would be helpful if you are you able to share copy of your summary sheet using MrExcel Addin

Dave
Hi Dave, I tried that and followed the steps but work admin police wont allow it. Here's a screen grab:
 

Attachments

  • Screenshot 2024-10-08 181337.png
    Screenshot 2024-10-08 181337.png
    52.9 KB · Views: 7
Upvote 0
I was planning to use the little blue arrows (images) as the buttons

Should not be a problem - do though ensure

- that each shape occupies the same Cell as the Sheet name listed in Column C
- that all the sheet names listed MATCH the actual tab name

let me know when all done

Dave
 
Upvote 0
Should not be a problem - do though ensure

- that each shape occupies the same Cell as the Sheet name listed in Column C
- that all the sheet names listed MATCH the actual tab name

let me know when all done

Dave
Ok, all done - the blue arrows all sits within the cells under Column C and the names match.
 

Attachments

  • Screenshot 2024-10-08 185945.png
    Screenshot 2024-10-08 185945.png
    15.4 KB · Views: 2
Upvote 0
Ok, all done - the blue arrows all sits within the cells under Column C and the names match.

OK place following codes in a STANDARD module

VBA Code:
Sub ShowSheet(ByVal SheetName As String)
    Dim sh          As String
    Dim shp         As Shape
    
    Application.ScreenUpdating = False
    For Each shp In ActiveSheet.Shapes
        If shp.TopLeftCell.Column = 3 Then
            sh = shp.TopLeftCell.Value
            If Evaluate("ISREF('" & sh & "'!A1)") Then
                Worksheets(sh).Visible = IIf(sh = SheetName, xlSheetVisible, xlSheetVeryHidden)
            End If
        End If
    Next shp
    Application.ScreenUpdating = True
    
End Sub

VBA Code:
Sub AssignShapes()
 Dim shp        As Shape
 Dim SheetName  As String
 
 For Each shp In ActiveSheet.Shapes
    SheetName = shp.TopLeftCell.Value
    If shp.TopLeftCell.Column = 3 Then _
    shp.OnAction = "'ShowSheet """ & SheetName & """ '"
 Next shp

End Sub

Run the AssignShapes code just once - this will assign each shape in column C to the common procedure ShowSheet.
When done, try clicking a shape and hopefully, the sheet name listed next to it should become visible.

Note - if you update the sheet name list in column C at anytime, you will need to run the AssignShapes code again.

Dave
 
Upvote 0
OK place following codes in a STANDARD module

VBA Code:
Sub ShowSheet(ByVal SheetName As String)
    Dim sh          As String
    Dim shp         As Shape
   
    Application.ScreenUpdating = False
    For Each shp In ActiveSheet.Shapes
        If shp.TopLeftCell.Column = 3 Then
            sh = shp.TopLeftCell.Value
            If Evaluate("ISREF('" & sh & "'!A1)") Then
                Worksheets(sh).Visible = IIf(sh = SheetName, xlSheetVisible, xlSheetVeryHidden)
            End If
        End If
    Next shp
    Application.ScreenUpdating = True
   
End Sub

VBA Code:
Sub AssignShapes()
 Dim shp        As Shape
 Dim SheetName  As String
 
 For Each shp In ActiveSheet.Shapes
    SheetName = shp.TopLeftCell.Value
    If shp.TopLeftCell.Column = 3 Then _
    shp.OnAction = "'ShowSheet """ & SheetName & """ '"
 Next shp

End Sub

Run the AssignShapes code just once - this will assign each shape in column C to the common procedure ShowSheet.
When done, try clicking a shape and hopefully, the sheet name listed next to it should become visible.

Note - if you update the sheet name list in column C at anytime, you will need to run the AssignShapes code again.

Dave
So im getting this error:
 

Attachments

  • Screenshot 2024-10-08 200551.png
    Screenshot 2024-10-08 200551.png
    17.8 KB · Views: 4
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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