Re: UserForm - Updating active record from user form.
Well this is what I have however after it goes through the first .Range... it jumps to refreshing the form which to me seems to be related to the lstMyData (second piece of code).
Private Sub cmdUpdate_Click()
Dim r As Excel.Range
Set r = Worksheets("ES").Range("A:A").Find(What:=lstMyData.List(lstMyData.ListIndex, 0), lookat:=xlWhole)
If Not r Is Nothing Then
With Worksheets("ES")
.Range("AB" & r.Row).Value = Control8.Value 'Code jumps from here to refresh the page and again after each line below.
.Range("AI" & r.Row).Value = Control9.Value
.Range("AJ" & r.Row).Value = Control10.Value
.Range("AK" & r.Row).Value = Control11.Value
.Range("AL" & r.Row).Value = Control12.Value
.Range("AM" & r.Row).Value = Control13.Value
.Range("AO" & r.Row).Value = Control14.Value
.Range("AP" & r.Row).Value = Control15.Value
End With
End If
Set r = Nothing
End Sub
Display More
The code it bounces to to reload the form:
Sub lstMyData_Click()
'dim the variables
Dim i As Integer
'find the selected list item
i = Me.lstMyData.ListIndex
Me.lstMyData.Selected(i) = True
'add the values to the text boxes
Me.Control1.Value = Me.lstMyData.Column(0, i)
Me.Control2.Value = Me.lstMyData.Column(28, i)
Me.Control3.Value = Me.lstMyData.Column(31, i)
Me.Control4.Value = Me.lstMyData.Column(32, i)
Me.Control5.Value = Me.lstMyData.Column(33, i)
Me.Control6.Value = Me.lstMyData.Column(1, i)
Me.Control7.Value = Me.lstMyData.Column(2, i)
Me.Control8.Value = Me.lstMyData.Column(27, i)
Me.Control9.Value = Me.lstMyData.Column(29, i)
Me.Control10.Value = Me.lstMyData.Column(34, i)
Me.Control11.Value = Me.lstMyData.Column(35, i)
Me.Control12.Value = Me.lstMyData.Column(36, i)
Me.Control13.Value = Me.lstMyData.Column(37, i)
Me.Control14.Value = Me.lstMyData.Column(38, i)
Me.Control15.Value = Me.lstMyData.Column(39, i)
End Sub
Display More
The final result overwrites the changes made in the form with data in the worksheet.