kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
How do I add a continuous range say 5 to 16? Instead of adding 5 and 16 as below?
I tried "To" and ":" for the "," but didn't work out.
I tried "To" and ":" for the "," but didn't work out.
Code:
Sub oSum()
Dim n&, s As Double, TbRay As Variant
TbRay = Array(5, 16)
For n = 0 To UBound(TbRay)
s = s + Val (UserForm1.Controls("TextBox" & TbRay(n)).Object.Value)
Next
UserForm1.TextBox17.Value = s
End Sub