Sorry, but that doesn't work,Once you have the TextBox name, then you can reference it's Properties w/
Me.Controls(tb)
Private Sub TextBox1_Change()
MsgBox "Current ActiveCell is " & ActiveSheet.Name & "!" & ActiveCell.Address & _
" and, the current TextBox is " & Me.ActiveControl.Name & ".", vbInformation, "Info Show" ' ERROR Me,ActiveControl is not an object
...
Private Sub TextBox1_Change()
Dim tObj
Set tObj = Me.ActiveControl
Me.DoStuff tObj
End Sub
Private Sub TextBox2_Change()
Set tObj = Me.ActiveControl
Me.DoStuff tObj
End Sub
Sub DoStuff(ByVal tb As Control)
Debug.Print tb.Name & " " & tb
End Sub
OMG ... please read my answers ... Me.ActiveControl doesn't existVBA Code:Private Sub TextBox1_Change() Dim tObj Set tObj = Me.ActiveControl Me.DoStuff tObj End Sub Private Sub TextBox2_Change() Set tObj = Me.ActiveControl Me.DoStuff tObj End Sub Sub DoStuff(ByVal tb As Control) Debug.Print tb.Name & " " & tb End Sub
It does if your controls are on a userform. If they they are on a sheet then there is no such thing as a Change event for FormControls.Me.ActiveControl doesn't exist
Private Sub TextBox1_Change()
MyTest(TextBox1)
End Sub
Private Sub TextBox2_Change()
MyTest(TextBox2)
End Sub
... and so on
It does if your controls are on a userform. If they they are on a sheet then there is no such thing as a Change event for FormControls.
So what exactly are you using?