ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,748
- Office Version
- 2007
- Platform
- Windows
Morning,
On my form i have a textbox called txtEmpID
I wish to change its name but when i do the code fails.
In the code shown ive also changed the id = part to match but still fails.
Do you see why please ?
This is the code for my userform.
On my form i have a textbox called txtEmpID
I wish to change its name but when i do the code fails.
In the code shown ive also changed the id = part to match but still fails.
Do you see why please ?
This is the code for my userform.
Rich (BB code):
Private Sub txtEmpID_AfterUpdate()
Dim id As Integer, rowcount As Integer, foundcell As Range
id = txtEmpID.Value
rowcount = Sheets("G INCOME").Cells(Rows.Count, 13).End(xlUp).Row ' THIS IS COLUMN NUMBER WHERE EMP ID LOCATED
With Worksheets("G INCOME").Range("M1:M" & rowcount) ' THIS IS CELL REFERENCE OF WHERE THE TEXT EMP ID IS LOCATED
Set foundcell = .Find(what:=id, LookIn:=xlValues)
If Not foundcell Is Nothing Then
TextBox1.Value = .Cells(foundcell.Row, 2)
TextBox2.Value = .Cells(foundcell.Row, 3)
TextBox3.Value = .Cells(foundcell.Row, 4)
TextBox4.Value = .Cells(foundcell.Row, 5)
TextBox5.Value = .Cells(foundcell.Row, 6)
Else
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox1.Value = ""
End If
End With
End Sub