bobshah2010
New Member
- Joined
- Nov 29, 2016
- Messages
- 39
Hi Guys,
I'm currently working on a macro that creates a shape on each visible sheet. And then I want to assign a Macro to those shapes.
This is what i have so far
It currently does what it needs to in terms of creating a shape and naming all the shapes onto one page at the start.
I just need it to create a shape on every other sheet, and make a link back to the "navigation" page.
Think of it like a Home button, that takes me back to the page with all the other buttons.
help will be much appreciated.
I'm currently working on a macro that creates a shape on each visible sheet. And then I want to assign a Macro to those shapes.
This is what i have so far
Code:
Sub AddNavigationPage()
Dim ws1 As Worksheet, ws As Worksheet
With ThisWorkbook
.Sheets.Add(Before:=.Sheets(1)).Name = "Navigation"
End With
Set ws1 = ActiveSheet
For Each ws In ThisWorkbook.Worksheets
If ws.Visible = xlSheetVisible Then
ws1.Cells(i + 1, 1) = ws.Name
'change the multiplier in next line to space the rectangles to suit
ws1.Shapes.AddShape(1, 100, 25 + i * 50, 100, 40).Select
With Selection
.Formula = "=A" & i + 1
.OnAction = "ActivateSheet"
End With
i = i + 1
End If
Next ws
For Each ws In ThisWorkbook.Worksheets
If ws.Visible = xlSheetVisible Then
ws.Shapes.AddShape(1, 100, 25 + i * 50, 100, 40).Select
With Selection
.Formula = "=A" & 2
.OnAction = "ShapeLink"
End With
i = i + 1
End If
Next ws
Columns("A").EntireColumn.Hidden = True
End Sub
Sub ActivateSheet()
Dim shp As Shape
Set shp = ActiveSheet.Shapes(Application.Caller)
s = shp.TextFrame.Characters.Text
Sheets(s).Select
End Sub
It currently does what it needs to in terms of creating a shape and naming all the shapes onto one page at the start.
I just need it to create a shape on every other sheet, and make a link back to the "navigation" page.
Think of it like a Home button, that takes me back to the page with all the other buttons.
help will be much appreciated.