francobonell
04-07-2021, 04:11 AM
Hi everyone :hi:
I am new here and this is my 1st post(so please be gentle with me :rotlaugh:), but will be a frequent user/visitor since my new job will be a lot easier with VBA!
I have a little issue with updating a new sheet with some scanned data from a Userform.
The Userform has 2 textboxes and a button to activate the code.
The idea is for the running code to check the scanned inputs and set an "X" in a new sheet in the cell that corresponds to the location of the row and column that corresponds to the scanned inputs.
So far, I have been able to set an "X" in a defined location(in this case the 6th column), but ideally the "X" should appear in the yellow marked cell - please see attached picture and code example.
I could of course hard code it to each desired cell but the worksheet will be used by multiple people and constantly updated with multiple rows and columns.
Any help anyone can offer is greatly appreciated :bow:.
Regards Franco.
Sub RegisterButton1_Click()
Dim ID As String
ID = Trim(TextBox2.Text)
lastrow = Worksheets("Docnums").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Worksheets("Docnums").Cells(i, 1).Value = ID Then
Worksheets("Docnums").Cells(i, 6).Value = "X"
End If
Next
TextBox1.Value = ""
TextBox2.Value = ""
Call DisplayMessage
Unload UserForm1
End Sub
I am new here and this is my 1st post(so please be gentle with me :rotlaugh:), but will be a frequent user/visitor since my new job will be a lot easier with VBA!
I have a little issue with updating a new sheet with some scanned data from a Userform.
The Userform has 2 textboxes and a button to activate the code.
The idea is for the running code to check the scanned inputs and set an "X" in a new sheet in the cell that corresponds to the location of the row and column that corresponds to the scanned inputs.
So far, I have been able to set an "X" in a defined location(in this case the 6th column), but ideally the "X" should appear in the yellow marked cell - please see attached picture and code example.
I could of course hard code it to each desired cell but the worksheet will be used by multiple people and constantly updated with multiple rows and columns.
Any help anyone can offer is greatly appreciated :bow:.
Regards Franco.
Sub RegisterButton1_Click()
Dim ID As String
ID = Trim(TextBox2.Text)
lastrow = Worksheets("Docnums").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow
If Worksheets("Docnums").Cells(i, 1).Value = ID Then
Worksheets("Docnums").Cells(i, 6).Value = "X"
End If
Next
TextBox1.Value = ""
TextBox2.Value = ""
Call DisplayMessage
Unload UserForm1
End Sub