good day
i have written a macro to find the answer to a sum i have for a single line in userforms Excel vba
but now trying to do the same through a loop i am not getting the textbox values
below is the code i am using currently that picks up text box names but not the values in the textbox
Private Sub CalculateGroup()
Dim WC As String
Dim W1 As String
Dim W2 As String
Dim D As String
Dim R As String
Dim T As Double
Dim W As String
Dim Q As String
Dim i As Integer
Dim J As Integer
Dim test As Integer
For i = 1 To 4
'test = UserForm3.Controls("Txtbox" & i & "A" & J).Value <----- this is the textbox where the answer goes
WC = "Txtbox" & i & "A" & 2
W1 = "Txtbox" & i & "A" & 3
W2 = "Txtbox" & i & "A" & 4
R = (Val(W1) + Val(WC)) - Val(W2)
T = Val(R)
Q = Val(R) / Val(W1)
W = Val(Q) * 100
'test.Value = W
' test.Text = Format(test, "0.00")
Next i
End Sub
i have tried Val("Txtbox" & i & "A" & 2) but it gives a 0 instead of textbox value
if anyone could help it would be much appreciated