I wrote a macro to search and change the captions of command buttons:
Private Sub fixcap()
If InStr(CommandButton1.Caption, "ABC") Then
CommandButton1.Caption = Application.Substitute(CommandButton1.Caption, "ABC", "ZZZ")
ElseIf InStr(CommandButton2.Caption, "AHY") Then
CommandButton2.Caption = Application.Substitute(CommandButton2.Caption, "ABC", "ZZZ")
....
End If
End Sub
If I have 20 buttons for each sheet and 50 sheets in total, keep writing the statements above will be awfully tedious. I tried to set up a For loop but it didn't work.
Could anyone help me out there?
Thanks in advance!
jqzhang
Private Sub fixcap()
If InStr(CommandButton1.Caption, "ABC") Then
CommandButton1.Caption = Application.Substitute(CommandButton1.Caption, "ABC", "ZZZ")
ElseIf InStr(CommandButton2.Caption, "AHY") Then
CommandButton2.Caption = Application.Substitute(CommandButton2.Caption, "ABC", "ZZZ")
....
End If
End Sub
If I have 20 buttons for each sheet and 50 sheets in total, keep writing the statements above will be awfully tedious. I tried to set up a For loop but it didn't work.
Could anyone help me out there?
Thanks in advance!
jqzhang