Update Row when ID is found

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,259
Office Version
  1. 2010
Platform
  1. Windows
Hi I have the code below for the ID which is textbox18, what I want is if a person has an update they go into the userform and enter the number id then what they want updated in other textboxes and then click the update button. what this should do is find the ID in sheet1 and update the same row with the ID. For example Textbox18 which is in the code for the update button to update row 'O'. The ID in sheet1 is located in Row G. can you help please.

Code:
Private Sub TextBox18_Change()
Dim TextBox18 As Integer
If Me.TextBox18.value = “” Then
Exit Sub
End If
Box18 = TextBox18.value
On Error Resume Next
Me.TextBox14.Value = Application.WorksheetFunction.VLookup(TextBox18, Sheets(“Sheet1”).Range(“05:R1087”), 7, 15)
End Sub

And the update button code is:-

Code:
Private Sub CommandButton1_Click()
End If

TextBox18 = Me.TextBox18.value
Sheets("Sheet1").Select
Dim rowselect As Double
rowselect = Me.TextBox18.value
rowselect = rowselect + 1
Rows(rowselect).Select
Cells(rowselect, 18) = Me.TextBox14.value

Dim emptyRow As Long
With ThisWorkbook.Sheets("Sheet1")
   emptyRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
 
   .Cells(emptyRow, 15).value = TextBox14.value
   .Cells(emptyRow, 16).value = TextBox15.value
   .Cells(emptyRow, 17).value = TextBox16.value
   .Cells(emptyRow, 18).value = TextBox17.value
End With
Unload Me
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi good morning, just an update with regards to what I am trying to do, I have a userform where TextBox18 is where people will will enter the ID Number for a member of staff, this data is then entered on Sheet1. When people have an update they go into userform2 and enter the ID number which is in Sheet1 then put it into textbox18 they then go into the other textboxes ie textbox14, textbox15, textbox16 and textbox17 with the updates, they then click the update button (Commandbutton1) so the updated data gets added into Sheet1 in the correct rows and in the same line as the ID Number. Textbox14 to TextBox17 are in Rows O to R, i have managed to copy the infor across to the correctr rows, but i dont know how to get it to match the same row as the ID Number can you help on this please, this is the code i have below for the update button, and the other code for the textbox, is where i colourocde the cells. Hope you can help me please?

My update button code below


Code:
Private Sub CommandButton1_Click()
Dim emptyRow As Long
With ThisWorkbook.Sheets("Sheet1")
   emptyRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
   .Cells(emptyRow, 15).value = TextBox14.value
   .Cells(emptyRow, 16).value = TextBox15.value
   .Cells(emptyRow, 17).value = TextBox16.value
   .Cells(emptyRow, 18).value = TextBox17.value
End With
Unload Me
End Sub


and for the textbox code

Code:
Private Sub TextBox14_Change()


  With ThisWorkbook.Sheets("Sheet1")


  emptyRow = .Cells(Rows.Count, "O").End(xlUp).Row + 1


    If Len(TextBox14.value) Then Range(.Cells(emptyRow, 1), .Cells(emptyRow, 18)).Interior.ColorIndex = 37


  End With


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top