Following Code works perfectly to add sum of three textboxes on User Form into a fourth box:
Private Sub CommandButton6_Click()
TextBox1318.Value = Val(TextBox1313.Value) + Val(TextBox1315.Value) + Val(TextBox1317.Value)
End Sub
But I need to "automate" it, as I need the same process across 368 sets, so tried the following two variations:
Private Sub CommandButton6_Click()
For T = 1318 To 1686 Step 8
Val(TextBox & T.value) = Val(TextBox & (T - 5).Value) + Val(TextBox & (T - 3).Value) + Val(TextBox & (T - 1).Value)
Next
End Sub
That generated the Error Message that "val" was an invalid qualified, so tried:
Private Sub CommandButton6_Click()
x = 1313
y = 1315
z = 1317
For T = 1318 To 1686 Step 8
ctrl("TextBox" & T).Value = ctrl("TextBox" & x).Value + ctrl("TextBox" & y).Value + ctrl("TextBox" & z).Value
x = x + 8
y = y + 8
z = z + 8
Next
End Sub
Which throws a Run-Time error 91 (Object Variable or With block variable not set)
Hope someone can provide the "right" syntax?
And would be even more useful if anyone can provide the Code that changes just the one textbox automatically if any of the three "trigger" columns in that row change, rather than looping through all of them if any row changes?
All solutions, suggestions and ideas welcome as ever
Ochimus
Bookmarks