I’m using this code to populate my UserForm ComboBoxes<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
<o></o>
<o></o>
<o></o>
And, this code to fill the cell values from the ComboBoxes<o></o>
<o></o>
<o></o>
<o></o>
So…<o></o>
How does the ComboBox.Value code change if AC2:AC5 values pre-exist?<o></o>
<o></o>
In other words<o></o>
IF AC2 is blank, Run Sub<o></o>
IF AC2.Value = “any value”, Then ComboBox1.Value = AC2.Value
Thanks for helping.
PS: Cleaner code for these two subs is appreciated<o></o>
<o></o>
Rich (BB code):
Private Sub UserForm_Initialize()
Label1.Caption = "Position " & Sheet1.Range("AB2").Value<o:p></o:p>
Label2.Caption = "Position " & Sheet1.Range("AB3").Value<o:p></o:p>
Label3.Caption = "Position " & Sheet1.Range("AB4").Value<o:p></o:p>
Label4.Caption = "Position " & Sheet1.Range("AB5").Value<o:p></o:p>
<o:p></o:p>
Dim x&<o:p></o:p>
With Sheet1<o:p></o:p>
For x = 1 To .Cells(Rows.Count, "D").End(xlUp).Row<o:p></o:p>
ComboBox1.AddItem (.Range("D" & x).Value)<o:p></o:p>
ComboBox2.AddItem (.Range("D" & x).Value)<o:p></o:p>
ComboBox3.AddItem (.Range("D" & x).Value)<o:p></o:p>
ComboBox4.AddItem (.Range("D" & x).Value)<o:p></o:p>
Next x<o:p></o:p>
End With<o:p></o:p>
<o:p></o:p>
End Sub
<o></o>
<o></o>
And, this code to fill the cell values from the ComboBoxes<o></o>
<o></o>
Rich (BB code):
Private Sub CommandButton1_Click()
With Sheet1<o:p></o:p>
.Range("AC2").Value = ComboBox1.Value<o:p></o:p>
.Range("AC3").Value = ComboBox2.Value<o:p></o:p>
.Range("AC4").Value = ComboBox3.Value<o:p></o:p>
.Range("AC5").Value = ComboBox4.Value<o:p></o:p>
End With<o:p></o:p>
<o:p></o:p>
Unload Me<o:p></o:p>
<o:p></o:p>
End Sub
<o></o>
So…<o></o>
How does the ComboBox.Value code change if AC2:AC5 values pre-exist?<o></o>
<o></o>
In other words<o></o>
IF AC2 is blank, Run Sub<o></o>
IF AC2.Value = “any value”, Then ComboBox1.Value = AC2.Value
Thanks for helping.
PS: Cleaner code for these two subs is appreciated<o></o>