Hello:
Please refer to attached file.
i have below code which successfully create a macro button and assign the macro correctly.
This is only doing for one sheet and i need to modify the code so that it does for all sheets of the workbook.
Sub CreateButton_New()
Dim btn As Button
'create the button in the active sheet.
'The 4 arguments are left, top, width and height --- i chose to base them off of cellular dimensions
Set btn = ActiveSheet.Buttons.Add( _
ActiveSheet.Columns(2).Left, _
ActiveSheet.Rows(2).Top, _
ActiveSheet.Columns(2).Width * 2, _
ActiveSheet.Rows(1).Height * 2)
'this is where you assing a macro to the btn
btn.OnAction = "ShowMessageBox"
'add a caption
btn.Text = "Click Me"
Set btn = Nothing
End Sub
Sub ShowMessageBox()
MsgBox "Hello"
End Sub
Let me know if you have any questions.
Thanks.
Riz
Bookmarks