I have a userform with comboboxes and a textbox. I would like the textbox to link to the cell 2 columns over from the value of combobox1. How would I go about doing so?
Also if the combobox/textbox is blank I would like the linked cells value to remain as is.
The code below for populating the userform comboboxes.
With Worksheets("ML")
.Cells(.Rows.Count, "B").End(xlUp).Offset(1, 0) = ComboBox1.Value
.Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0) = ComboBox2.Value
.Cells(Rows.Count, "B").End(xlUp).Offset(-1, 1).Resize(, 3).AutoFill
.Cells(Rows.Count, "B").End(xlUp).Offset(-1, 1).Resize(, 3).Resize(2)
With .Cells(Rows.Count, "B").End(xlUp).Offset(-1, 1).Resize(, 3).Resize(2)
.Borders.LineStyle = xlContinuous
End With
With Worksheets("CT")
.Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0) = ComboBox2.Value
.Cells(Rows.Count, "A").End(xlUp).Offset(-1, 1).Resize(, 21).AutoFill
.Cells(Rows.Count, "A").End(xlUp).Offset(-1, 1).Resize(, 21).Resize(2)
With .Cells(Rows.Count, "A").End(xlUp).Offset(-1, 1).Resize(, 3).Resize(2)
.Borders.LineStyle = xlContinuous
End With
ActiveWorkbook.RefreshAll
Unload Me
End Sub
I would like the value of the Combobox1 to display at the next available cell in column A then I would like the textbox1 to show up in the same row as the combobox value but in column AE. In the same row as both the textbox value and the combobox value I would like the columns up to AM to be filled down. Finally I would like the columns up to AM have borders.
.Cells(.Rows.Count, "B").End(xlUp).Offset(1, 0) = ComboBox1.Value
, just add 2 to the columnoffset
, i.e.:.Cells(.Rows.Count, "B").End(xlUp).Offset(1, 2) = TextBox.Value
. As for keeping values if blank, you should wrap each of your value allocations within an if statement, something likeif combobox1.value <> "" then...
– FABTextBox
or vice versa – GMalc