ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to get a range of values into a combo placed on USERFORM? (https://www.excelbanter.com/excel-programming/295743-how-get-range-values-into-combo-placed-userform.html)

harinath

How to get a range of values into a combo placed on USERFORM?
 
Hi All

Please let me know some method for filling range of data to combobox on a userform from spreadsheet
The range data will be present on the spreadsheet
I filled the combo by entering individual cell values in the VBA code.Instead of doing like thi
is there any method of selecting a range of values from a sheet and put the same data into the combo in one go

Please put some light on this

Thank
Harinath

Leo Heuser[_3_]

How to get a range of values into a combo placed on USERFORM?
 
Hi Harinath

Here's one way to do it:

For data in a column:

Private Sub UserForm_Initialize()
Dim DataRange As Range
Dim DataRangeValue As Variant

Set DataRange = Sheets("Sheet1").Range("A1:A7")
DataRangeValue = DataRange.Value

Me.ComboBox1.List = DataRangeValue
End Sub


For data in a row

Private Sub UserForm_Initialize()
Dim DataRange As Range
Dim DataRangeValue As Variant

Set DataRange = Sheets("Sheet1").Range("A1:G1")
DataRangeValue = DataRange.Value

Me.ComboBox1.Column = DataRangeValue
End Sub


--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"Harinath" skrev i en meddelelse
...
Hi All,

Please let me know some method for filling range of data to combobox on a

userform from spreadsheet.
The range data will be present on the spreadsheet.
I filled the combo by entering individual cell values in the VBA

code.Instead of doing like this
is there any method of selecting a range of values from a sheet and put

the same data into the combo in one go.

Please put some light on this.

Thanks
Harinath




BrianB

How to get a range of values into a combo placed on USERFORM?
 
Controls start numbering at zero so :-

'-------------------------------------------
'- initialise form
Private Sub UserForm_Initialize()
Set DataSheet = ThisWorkbook.Worksheets("data")
Set MyList = DataSheet.Range("FileList")
Rw = 1
While MyList.Cells(Rw, 1).Value < ""
ComboBox1.AddItem
ComboBox1.List(Rw - 1) = MyList.Cells(Rw, 1).Value
Rw = Rw + 1
Wend
End Sub
'---------------------------------

--
Message posted from http://www.ExcelForum.com


Tim Zych[_7_]

How to get a range of values into a combo placed on USERFORM?
 
Combobox1.List = Range("A1:A100").Value

"Harinath" wrote in message
...
Hi All,

Please let me know some method for filling range of data to combobox on a

userform from spreadsheet.
The range data will be present on the spreadsheet.
I filled the combo by entering individual cell values in the VBA

code.Instead of doing like this
is there any method of selecting a range of values from a sheet and put

the same data into the combo in one go.

Please put some light on this.

Thanks
Harinath





All times are GMT +1. The time now is 10:52 PM.

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