At the moment I have a userform which when submitted posts the data to the next empty row in excel. However I have made it so that the user can view other records on the userform. However I don't know how to enable the user to then amend that record. At the moment it just posts all the information into the next cell.
The code to view an existing record is
So, I guess I need to put a clause in which specifies that if the uniqueID value exists in Range("A3:A" & lngLastRow) Then Activecell = where this is true.
but I can't figure out how to say this. Hope that makes sense to somebody. Thanks in advance.
The code to view an existing record is
Code:
Private Sub UserForm_Initialize()
Dim lngLastRow As Long
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
cboUniqueID.List = Worksheets("Sheet1").Range("A3:A" & lngLastRow).Value
End Sub
Private Sub cboAccidentID_Change()
If cboUniqueID.ListIndex <> -1 Then
txtFirstName.Value = Range("A" & cboUniqueID.ListIndex + 3).Offset(, 1) 'etc
End Sub
ActiveWorkbook.Sheets("Sheet1").Activate
Range("A3").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = cboUniqueID.Value 'etc
End Sub
So, I guess I need to put a clause in which specifies that if the uniqueID value exists in Range("A3:A" & lngLastRow) Then Activecell = where this is true.
but I can't figure out how to say this. Hope that makes sense to somebody. Thanks in advance.