I have an Excel spreadsheet consisting of two sheets (Sheet1 and Sheet2).
In each sheet I have a Button 1.
In order to move this butt
It is pretty simple. Follow the same logic and declare a Optional boolean variable say, AllSheets.
Sub Sample()
MoveButton Sheet1, "Button 1", True
End Sub
Sub MoveButton(sh As Worksheet, btnName As String, Optional AllSheets As Boolean)
Dim Range_Position As Range
Dim ws As Worksheet
Set Range_Position = sh.Range("D9:E11")
If AllSheets = True Then
For Each ws In ThisWorkbook.Sheets
With ws.Buttons(btnName)
.Top = Range_Position.Top
.Left = Range_Position.Left
.Width = Range_Position.Width
.Height = Range_Position.Height
.Text = "Button"
End With
Next ws
Else
With sh.Buttons(btnName)
.Top = Range_Position.Top
.Left = Range_Position.Left
.Width = Range_Position.Width
.Height = Range_Position.Height
.Text = "Button"
End With
End If
End Sub