ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   "Which control to use in a UserForm?" (https://www.excelbanter.com/excel-programming/392532-control-use-userform.html)

Don

"Which control to use in a UserForm?"
 
This is my first shot at this task so be patient, please...:)

I would like to develop a UserForm2 that can be called from an option button
on another UserForm1. UF1 is already done and works fine.

On UF2 would be either a ComboBox or a ListBox, or whatever might be
appropriate to get the following job done. I have a list of names on Sheet1
in ColA. This list would be loaded into the ?box so that the OP could scroll
to and highlight a name for an action. Then code assigned to an "OK" button
would do the following:

Determine the Row the name is in, Select that entire Row and ClearContents
(not Delete) of same. Delete introduces errors on other Sheets in the WB.

I'm also having a bit of trouble loading Col A into a ListBox or ComboBox.
(this has to be done everytime UF2 is called as the list does change from
time to time) If it matters, I already have a macro that will be called that
sorts Sheet1 using Col A for the sort so there are no empty Rows in Col A,
prior to calling UF2.

Any help would be greatly appreciated.

TIA.... Don

Bob Phillips

"Which control to use in a UserForm?"
 

"Don" wrote in message
...
This is my first shot at this task so be patient, please...:)

I would like to develop a UserForm2 that can be called from an option
button
on another UserForm1. UF1 is already done and works fine.

On UF2 would be either a ComboBox or a ListBox, or whatever might be
appropriate to get the following job done. I have a list of names on
Sheet1
in ColA. This list would be loaded into the ?box so that the OP could
scroll
to and highlight a name for an action.



Combobox sounds right


Then code assigned to an "OK" button would do the following:
Determine the Row the name is in, Select that entire Row and ClearContents
(not Delete) of same. Delete introduces errors on other Sheets in the WB.



iRow = Application.Match(ComboBox1.Value,
Worksheets("Sheet1").Columns(1),0)

If iRow 0 Then
Rows(i).ClearContents
End If


I'm also having a bit of trouble loading Col A into a ListBox or ComboBox.
(this has to be done everytime UF2 is called as the list does change from
time to time) If it matters, I already have a macro that will be called
that
sorts Sheet1 using Col A for the sort so there are no empty Rows in Col A,
prior to calling UF2.


With Worksheets("Sheet1").
iLastRow = .Cells(.Rows.Count,"A").End(xlUp).Row
For i = 1 To iLastRow
CombobBox1.AddItem .Cells(i,"A").Value
Next i
End With



Don

"Which control to use in a UserForm?"
 
Thanks for the very quick reply Bob....I'll see if I can make it work and
post later the results.....Tks again... Don

"Bob Phillips" wrote:


"Don" wrote in message
...
This is my first shot at this task so be patient, please...:)

I would like to develop a UserForm2 that can be called from an option
button
on another UserForm1. UF1 is already done and works fine.

On UF2 would be either a ComboBox or a ListBox, or whatever might be
appropriate to get the following job done. I have a list of names on
Sheet1
in ColA. This list would be loaded into the ?box so that the OP could
scroll
to and highlight a name for an action.



Combobox sounds right


Then code assigned to an "OK" button would do the following:
Determine the Row the name is in, Select that entire Row and ClearContents
(not Delete) of same. Delete introduces errors on other Sheets in the WB.



iRow = Application.Match(ComboBox1.Value,
Worksheets("Sheet1").Columns(1),0)

If iRow 0 Then
Rows(i).ClearContents
End If


I'm also having a bit of trouble loading Col A into a ListBox or ComboBox.
(this has to be done everytime UF2 is called as the list does change from
time to time) If it matters, I already have a macro that will be called
that
sorts Sheet1 using Col A for the sort so there are no empty Rows in Col A,
prior to calling UF2.


With Worksheets("Sheet1").
iLastRow = .Cells(.Rows.Count,"A").End(xlUp).Row
For i = 1 To iLastRow
CombobBox1.AddItem .Cells(i,"A").Value
Next i
End With





All times are GMT +1. The time now is 11:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com