I have a Combobox in a Userform in word. I am trying to make it populate the revision number of the document. At the moment I can only get it to increase in full numbers 01, 02, 03, etc.
What I actually want it to do is increase in 0.1 increments, so - 1.0, 1.1, 1.2, 1.3, etc.
I've tried changing the formatting from "00" to "0.0" or "0.1" but that just continues the format and doesn't add 0.1 to each subsequent level.
Private Sub UserForm_Initialize()
Dim sSaved As String
Dim i As Integer
Dim docType As String
On Error Resume Next
For i = 0 To 20
cboRev.AddItem Format(i, "00")
Next i
Decimals are non-integer by definition. Declare i
as double instead, and use Step 0.1
to increment by a tenth:
Private Sub UserForm_Initialize()
Dim sSaved As String
Dim i As Double
Dim docType As String
For i = 0 To 20.1 Step 0.1
cboRev.AddItem Application.WorksheetFunction.Round(i, 1)
'cboRev.AddItem Format(i, "0.0") 'alternative
Next i