PLwolves87
New Member
- Joined
- Jan 6, 2023
- Messages
- 31
- Office Version
- 365
- Platform
- Windows
Hi All,
so my userform search and display button works and brings back the correct data, but i have now made a UPDATE button but when i click on the button i get an error " BLOCK IF WITHOUT END IF" the data which i want updating doesnt update at the moment because of this error, hope you can help, please see below code.
if someone knows a better way to code this please feel free.
so my userform search and display button works and brings back the correct data, but i have now made a UPDATE button but when i click on the button i get an error " BLOCK IF WITHOUT END IF" the data which i want updating doesnt update at the moment because of this error, hope you can help, please see below code.
if someone knows a better way to code this please feel free.
VBA Code:
Private Sub CommandButton5_Click()
Dim x As Long
Dim y As Long
targetsheet = Account1.Value & Account2.Value
If targetsheet = "" Then
x = Worksheets(targetsheet).Range("A" & Rows.Count).End(xlUp).Row
For y = 3 To x
If Worksheets(targetsheet).Cells(y, 1).Value = TextBox1.Value Then
Worksheets(targetsheet).Cells(y, 2) = TextBox47.Value
Worksheets(targetsheet).Cells(y, 3) = TextBox2.Value
Worksheets(targetsheet).Cells(y, 4) = TextBox3.Value
Worksheets(targetsheet).Cells(y, 5) = TextBox4.Value
Worksheets(targetsheet).Cells(y, 6) = TextBox5.Value
Worksheets(targetsheet).Cells(y, 7) = TextBox6.Value
Worksheets(targetsheet).Cells(y, 8) = TextBox7.Value
Worksheets(targetsheet).Cells(y, 10) = TextBox8.Value
Worksheets(targetsheet).Cells(y, 11) = TextBox9.Value
Worksheets(targetsheet).Cells(y, 12) = TextBox10.Value
Worksheets(targetsheet).Cells(y, 13) = TextBox11.Value
Worksheets(targetsheet).Cells(y, 14) = TextBox12.Value
Worksheets(targetsheet).Cells(y, 15) = TextBox13.Value
Worksheets(targetsheet).Cells(y, 16) = TextBox14.Value
Worksheets(targetsheet).Cells(y, 17) = TextBox15.Value
Worksheets(targetsheet).Cells(y, 18) = TextBox16.Value
Worksheets(targetsheet).Cells(y, 19) = TextBox17.Value
Worksheets(targetsheet).Cells(y, 20) = TextBox18.Value
Worksheets(targetsheet).Cells(y, 21) = TextBox19.Value
Worksheets(targetsheet).Cells(y, 22) = TextBox20.Value
Worksheets(targetsheet).Cells(y, 23) = TextBox21.Value
Worksheets(targetsheet).Cells(y, 24) = TextBox22.Value
Worksheets(targetsheet).Cells(y, 25) = TextBox23.Value
Worksheets(targetsheet).Cells(y, 26) = TextBox24.Value
Worksheets(targetsheet).Cells(y, 27) = TextBox25.Value
Worksheets(targetsheet).Cells(y, 28) = TextBox26.Value
Worksheets(targetsheet).Cells(y, 29) = TextBox27.Value
Worksheets(targetsheet).Cells(y, 30) = TextBox28.Value
Worksheets(targetsheet).Cells(y, 31) = TextBox29.Value
Worksheets(targetsheet).Cells(y, 32) = TextBox30.Value
Worksheets(targetsheet).Cells(y, 33) = TextBox31.Value
Worksheets(targetsheet).Cells(y, 34) = TextBox32.Value
Worksheets(targetsheet).Cells(y, 35) = TextBox33.Value
Worksheets(targetsheet).Cells(y, 36) = TextBox34.Value
Worksheets(targetsheet).Cells(y, 37) = TextBox35.Value
Worksheets(targetsheet).Cells(y, 38) = TextBox36.Value
Worksheets(targetsheet).Cells(y, 39) = TextBox37.Value
Worksheets(targetsheet).Cells(y, 40) = TextBox38.Value
Worksheets(targetsheet).Cells(y, 41) = TextBox39.Value
Worksheets(targetsheet).Cells(y, 42) = TextBox40.Value
Worksheets(targetsheet).Cells(y, 43) = TextBox41.Value
Worksheets(targetsheet).Cells(y, 44) = TextBox42.Value
Worksheets(targetsheet).Cells(y, 45) = TextBox43.Value
Worksheets(targetsheet).Cells(y, 46) = TextBox44.Value
Worksheets(targetsheet).Cells(y, 47) = TextBox45.Value
Worksheets(targetsheet).Cells(y, 48) = TextBox46.Value
End If
Next y
MsgBox "update complete"
End Sub
Last edited by a moderator: