kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Hello ,
I have this challenge here:
I am using this code to add on my userform then I got into a big trap and I need help to get out.
Now the textboxes I am adding are all not having the same naming as the “Rw”. One is Rw10 and the other is Reg10. I wish I can change them all to have the same naming but that will give me much headache so I am thinking of a way to add them from the macro I have below. Thanks in advance.
Kelly
I have this challenge here:
I am using this code to add on my userform then I got into a big trap and I need help to get out.
Now the textboxes I am adding are all not having the same naming as the “Rw”. One is Rw10 and the other is Reg10. I wish I can change them all to have the same naming but that will give me much headache so I am thinking of a way to add them from the macro I have below. Thanks in advance.
Kelly
Code:
Sub oSum()
Dim n As Integer, s As Double, TbRay As Variant
TbRay = Array(10, 30)
For n = 0 To UBound(TbRay)
s = s + Val(Userform1.Controls("Rw" & TbRay(n)).Object.Value)
Next n
Userform1.Label1.Caption = s
End Sub