Hi Peeps
I'm kinda embarrassed
to ask this, because it's First-Grade stuff to most of you, I'm sure, but here goes...
I’m populating a list from a UserForm with 20+ controls on it; ComboBoxes, TextBoxes, ScrollBars, etc.
Once the user has finished entering/checking/picking/scrolling and so on, they click the OK button on the form and code similar to this appends the control values in the next blank row at the bottom of the list:
Private Sub btnOK_Click()
With Sheets("Lists"
.Range("A65536"
.End(xlUp).Offset(1, 0).Select
With ActiveCell
.Offset(0, 1).Value = "First"
.Offset(0, 2).Value = "Second"
.Offset(0, 3).Value = "Third"
……. SO ON AND SO FORTH ……
.Offset(0, 20).Value = "Twentieth"
End With
End With
End Sub
Bearing in mind Bowers74’s advice about Selecting and Activating being bad practice, can anyone suggest a more efficient & elegant way of doing this?
I thought of looping all the control values into an array of some kind, then slapping the array contents onto the next empty row, but I don’t have a clue how to go about it!
Thanks in advance,
Chris
I'm kinda embarrassed
![[blush] [blush] [blush]](/data/assets/smilies/blush.gif)
I’m populating a list from a UserForm with 20+ controls on it; ComboBoxes, TextBoxes, ScrollBars, etc.
Once the user has finished entering/checking/picking/scrolling and so on, they click the OK button on the form and code similar to this appends the control values in the next blank row at the bottom of the list:
Private Sub btnOK_Click()
With Sheets("Lists"
.Range("A65536"
With ActiveCell
.Offset(0, 1).Value = "First"
.Offset(0, 2).Value = "Second"
.Offset(0, 3).Value = "Third"
……. SO ON AND SO FORTH ……
.Offset(0, 20).Value = "Twentieth"
End With
End With
End Sub
Bearing in mind Bowers74’s advice about Selecting and Activating being bad practice, can anyone suggest a more efficient & elegant way of doing this?
I thought of looping all the control values into an array of some kind, then slapping the array contents onto the next empty row, but I don’t have a clue how to go about it!
Thanks in advance,
Chris