RobbieC
Active Member
- Joined
- Dec 14, 2016
- Messages
- 376
- Office Version
- 2010
- Platform
- Windows
Hi there, I have a userform with 10 text input fields.
Each is named txt1 txt2 txt3.... txt10
The user can enter info into any of the boxes, but not necessarily all of them...
When the user clicks the UPDATE button, it creates a string of the values and inserts a comma if <>"" :
This all works fine, but I'd like to replace the final comma in the final TotalString with " and"
If you can point me in the right direction, I'd be very grateful
Thanks
Each is named txt1 txt2 txt3.... txt10
The user can enter info into any of the boxes, but not necessarily all of them...
When the user clicks the UPDATE button, it creates a string of the values and inserts a comma if <>"" :
Code:
Dim TotalString As String
TotalString = ""
Dim txtVar As String
Dim txtNumVar(1 To 10) As String
For i = 1 To 10
txtVar = "txt" & i
txtNumVar(i) = Me.Controls(txtVar).Value
If txtNumVar(i) <> "" Then txtNumVar(i) = ", " & txtNumVar(i)
TotalString = TotalString & (txtNumVar(i))
Next
Code:
TotalString = TotalString (find last "," and replace with " and")
If you can point me in the right direction, I'd be very grateful
Thanks