i have added few dynamic Textboxes to userform with run time on userfrom activate. The Taxtboxes are named as txt1 , txt 2 , txt 3 an so on
i want to change worksheet cell A1 value when txt1 value changes and change worksheet cell B1 value when txt2 value changes and so on.
i do not want to achieve it with following by adding change event for each textbox, as textboxes are added on run time with add control.
VBA Code:
Private sub txt1_change()
worksheets("database").range("A1"),value = txt1.value
End sub
So i tried other methods as follows but no success.
I added static Textbox in userform and named it as "txtid'
VBA Code:
Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) ' to get value in txtid of textbox when user start typing in textbox but no success.
txtid.value = ActiveControl.Name 'to get name of selected textbox
End Sub
Private sub txtid_change()
Dim a As integer
Dim update UpdateValue As String
a = 1
Updatevalue = "txt" & a 'txt is txtbox starting name string
for n = 1 to 15
worksheets("database").cells(1, 1 + a).value = Updatevalue
next n
a = a + 1
End sub
i want to update the value in worksheet on real time when user changes textbox value it in userform.
i am not expert with vba.