PDA

View Full Version : [SOLVED:] is it possible: If Me.Controls("CommandButton" & i).clicked



kofatoto
08-24-2017, 11:02 PM
hello
is it possible:

If Me.Controls("CommandButton" & i).clicked Then
Sheets("tt").Range("C" & i).Value = Me.Controls("CommandButton" & i).Caption
End If

mdmackillop
08-25-2017, 02:06 AM
You could build a Class for Command Buttons (http://www.vbaexpress.com/kb/getarticle.php?kb_id=85) or

Private Sub CommandButton1_Click()
Call FillCell(1)
End Sub
Private Sub CommandButton2_Click()
Call FillCell(2)
End Sub


Sub FillCell(i)
Sheets("tt").Range("C" & i).Value = Me.Controls("CommandButton" & i).Caption
End Sub

kofatoto
08-25-2017, 02:50 AM
thank you very much