The_Steward
Board Regular
- Joined
- Nov 26, 2020
- Messages
- 63
- Office Version
- 365
- Platform
- Windows
I need to create a set of buttons (using a for loop) that all have the ability to clear the contents of a select amount of cells on different worksheets (all worksheets are identical).
All the worksheet names are in a list in a separate sheet (Column 8/H in 'Code and Data Centre') , and I have already created a for loop to create all the buttons, and a macro that will clear the cells, but I just don't know how to link each button with the separate sheets.
All the buttons will be on a directory page (SIL Selection)
Any suggestions are very welcome. Thankyou in advance!
This is the two macros I have so far:
All the worksheet names are in a list in a separate sheet (Column 8/H in 'Code and Data Centre') , and I have already created a for loop to create all the buttons, and a macro that will clear the cells, but I just don't know how to link each button with the separate sheets.
All the buttons will be on a directory page (SIL Selection)
Any suggestions are very welcome. Thankyou in advance!
This is the two macros I have so far:
VBA Code:
Sub create_clearSILButton()
Dim macrobook As Workbook
Set macrobook = ThisWorkbook
Dim y As Long
Dim x As Long
Dim iconloop As Long
Dim SilSelection As Worksheet
Set SilSelection = macrobook.Sheets("SIL House Selection")
SilSelection.Activate
x = -400
y = -60
For iconloop = 1 To 3
Dim icons As Picture
Set icons = SilSelection.Pictures.Insert("https://cdn.hubblecontent.osi.office.net/icons/publish/icons_eraser_m/eraser_m.svg")
With icons.Select
Selection.ShapeRange.ScaleWidth 0.7505082319, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.7505084746, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.IncrementLeft x
Selection.ShapeRange.IncrementTop y
End With
y = y + 60
x = -400
Next iconloop
End Sub
VBA Code:
Sub ClearSILContent()
'
' ClearSILContent Macro
' Clear all content for a SIL page so it is restored to default
'
'
Range("H6:I8,H15:I17,M6:O25").Select
Selection.ClearContents
End Sub