Hi guys,
I have a listbox linked to an excel sheet and I have created a small "update" button that allows me to modify each entry.
However, the code only runs on the first row of code and I do not understand why it does not update the following fields. It seems as if VBA stops looking at the remainder of the code once the first action has been done.
My question is:
what is wrong with this code? Is it a setting of VBA which is wrong?
I look forward to your feedback!
Have a nice one!
Edo
I have a listbox linked to an excel sheet and I have created a small "update" button that allows me to modify each entry.
However, the code only runs on the first row of code and I do not understand why it does not update the following fields. It seems as if VBA stops looking at the remainder of the code once the first action has been done.
Code:
If Me.txtbox28.Value = "" Then
MsgBox "SL No Can Not be Blank!!!", vbExclamation, "SL No"
Exit Sub
End If
SLNo = Me.txtbox28.Value
Sheets("Sheet1").Select
Dim msg As String
Dim ans As String
Dim rowselect As Doublerowselect = Me.txtbox28.Value
rowselect = rowselect + 1
Rows(rowselect).Select
Cells(rowselect, 2) = Me.txtbox1.Value
'the macro seems not to go further than here and the below is not executed. If I change the above row with any of the below, the macro will run on it, but not on the following ones.
Cells(rowselect, 3) = Me.txtbox2.Text
Cells(rowselect, 4) = Me.txtbox3.Value
Cells(rowselect, 5) = Me.txtbox4.Value
Cells(rowselect, 6) = Me.txtbox5.Value
Cells(rowselect, 7) = Me.txtbox6.Value
Cells(rowselect, 8) = Me.txtbox7.Value
Cells(rowselect, 9) = Me.txtbox8.Value
Cells(rowselect, 10) = Me.txtbox9.Value
Cells(rowselect, 12) = Me.txtbox11.Value
Cells(rowselect, 13) = Me.txtbox12.Value
Cells(rowselect, 21) = Me.txtbox20.Value
Cells(rowselect, 22) = Me.txtbox21.Value
Cells(rowselect, 23) = Me.txtbox22.Value
Cells(rowselect, 24) = Me.txtbox23.Value
Cells(rowselect, 25) = Me.txtbox24.Value
Cells(rowselect, 26) = Me.txtbox25.Value
Cells(rowselect, 27) = Me.txtbox26.Value
Cells(rowselect, 28) = Me.txtbox27.Value
Cells(rowselect, 29) = Me.txtbox28.Value
rowselect = rowselect - 1
msg = "Sl No " & rowselect & " Successfully Updated...Continue?"
Unload Me
ans = MsgBox(msg, vbYesNo, "Update")If ans = vbYes Then
UF.Show
Else
Sheets("Sheet1").Select
End If
My question is:
what is wrong with this code? Is it a setting of VBA which is wrong?
I look forward to your feedback!
Have a nice one!
Edo