Hello. i hope somebody is able to help me, my knowledge of VBA isn't great to begin with and i havnt been able to find the answer online (pr at least one that i can follow) .
i have a spreadsheet with several userforms. one to add, remove and edit existing users on a sheet. the add and delete ones i have been able to do but i need some help with the VBA for the form to edit. so far i have the below which populates a combo box which you can then use to select which person to edit. The code i have pulls throw the data from the relevant columnsinto the userform, but it won't allow me to edit the data on the form and have that written back to the sheet.
Would someone be able to help me with what i need to add / change to write it back to the sheet?, and if possible help me format so that TextBox 6 and 7 show the time in the right format rather than convert it to text please? Or have it so that if a textbox is blank it doesnt overwrite the existing value on the row i have linked a sample sheet with some dummy data
Thank you in advance for any help
Sample Sheet
i have a spreadsheet with several userforms. one to add, remove and edit existing users on a sheet. the add and delete ones i have been able to do but i need some help with the VBA for the form to edit. so far i have the below which populates a combo box which you can then use to select which person to edit. The code i have pulls throw the data from the relevant columnsinto the userform, but it won't allow me to edit the data on the form and have that written back to the sheet.
VBA Code:
Private Sub ComboBox2_Change()
Dim i As Long, LastRow As Long
LastRow = Sheets("Daily Report").Range("AL" & Rows.Count).End(xlUp).Row
For i = 1 To LastRow
If Sheets("Daily Report").Cells(i, "D").Value = (Me.ComboBox2) Or _
Sheets("Daily Report").Cells(i, "D").Value = Val(Me.ComboBox2) Then
Me.TextBox1 = Sheets("Daily Report").Cells(i, "D").Value
Me.TextBox2 = Sheets("Daily Report").Cells(i, "AK").Value
Me.TextBox3 = Sheets("Daily Report").Cells(i, "B").Value
Me.TextBox4 = Sheets("Daily Report").Cells(i, "A").Value
Me.TextBox5 = Sheets("Daily Report").Cells(i, "C").Value
Me.ComboBox1 = Sheets("Daily Report").Cells(i, "AM").Value
Me.TextBox6 = Sheets("Daily Report").Cells(i, "AE").Value
Me.TextBox7 = Sheets("Daily Report").Cells(i, "AF").Value
End If
Next
End Sub
Would someone be able to help me with what i need to add / change to write it back to the sheet?, and if possible help me format so that TextBox 6 and 7 show the time in the right format rather than convert it to text please? Or have it so that if a textbox is blank it doesnt overwrite the existing value on the row i have linked a sample sheet with some dummy data
Thank you in advance for any help
Sample Sheet