Hi all
I have a vba form with multipage form in it
the inputs on all 6 pages are the same i have it working fine but i have a lot of code for it is there a way to use a for next to populate each page.
Private Sub UserForm_Initialize()
txtSfcWnd1.Value = "" 'Surface Wind
txtCrossWnd1.Value = "" 'Cross Wind
txtVsby1.Value = "" 'Visibility
For i = 1 To 6
With cboFog(x) 'Fog
.AddItem "nil"
.AddItem "f-"
.AddItem "f"
.AddItem "f+"
End With
cboFog(x).Value = "nil"
Next
With cboIcg1 'Icing
.AddItem "nil"
.AddItem "i-"
.AddItem "i"
.AddItem "i+"
End With
cboIcg1.Value = "nil"
With cboTurb1 'Turbulance
.AddItem "nil"
.AddItem "t-"
.AddItem "t"
.AddItem "t+"
End With
cboTurb1.Value = "nil"
For i = 0 To 8: cboCldCov1.AddItem i: Next i ' Cloud
cboCldCov1.Value = "0" 'Cloud Cover
txtCig1.Value = "" 'Ceiling
With cboMPhase1 'MoonPhase
.AddItem "nil"
.AddItem "New Moon"
.AddItem "Full Moon"
End With
cboMPhase1.Value = "nil"
txtTemp1.Value = "" 'Temperature
With cboPrecip1 'Precipitation
.AddItem "nil"
.AddItem "p-"
.AddItem "p"
.AddItem "p+"
End With
cboPrecip1.Value = "nil"
End Sub
each page page has the same data except the names are different eg cboPrecip1.value for page 1
cboPrecip2.value for page 2 ect.
is there a way to cut this code down.
thanks ed
I have a vba form with multipage form in it
the inputs on all 6 pages are the same i have it working fine but i have a lot of code for it is there a way to use a for next to populate each page.
Private Sub UserForm_Initialize()
txtSfcWnd1.Value = "" 'Surface Wind
txtCrossWnd1.Value = "" 'Cross Wind
txtVsby1.Value = "" 'Visibility
For i = 1 To 6
With cboFog(x) 'Fog
.AddItem "nil"
.AddItem "f-"
.AddItem "f"
.AddItem "f+"
End With
cboFog(x).Value = "nil"
Next
With cboIcg1 'Icing
.AddItem "nil"
.AddItem "i-"
.AddItem "i"
.AddItem "i+"
End With
cboIcg1.Value = "nil"
With cboTurb1 'Turbulance
.AddItem "nil"
.AddItem "t-"
.AddItem "t"
.AddItem "t+"
End With
cboTurb1.Value = "nil"
For i = 0 To 8: cboCldCov1.AddItem i: Next i ' Cloud
cboCldCov1.Value = "0" 'Cloud Cover
txtCig1.Value = "" 'Ceiling
With cboMPhase1 'MoonPhase
.AddItem "nil"
.AddItem "New Moon"
.AddItem "Full Moon"
End With
cboMPhase1.Value = "nil"
txtTemp1.Value = "" 'Temperature
With cboPrecip1 'Precipitation
.AddItem "nil"
.AddItem "p-"
.AddItem "p"
.AddItem "p+"
End With
cboPrecip1.Value = "nil"
End Sub
each page page has the same data except the names are different eg cboPrecip1.value for page 1
cboPrecip2.value for page 2 ect.
is there a way to cut this code down.
thanks ed