ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Populating listbox (https://www.excelbanter.com/excel-discussion-misc-queries/187465-populating-listbox.html)

Mick[_2_]

Populating listbox
 
Hi

Have a range of sheets:

12May
19May etc

In a userform I grab the correct sheet using:

Dim grabdate As String
'a drop down with names of the sheets
grabdate = cboE2WeekBeg.Value
Sheets(grabdate).Select

All works fine.

I then want a listbox to display a set range of cells but from the
selected worksheet.

Have tried
lstE2WeekSelected.RowSource = ActiveSheet.Range("a3:j26")

and

sheets(grabdate!a3:j26)

but both throw errors.

Any help appreciated

Mick

Dave Peterson

Populating listbox
 
I'd try:

lstE2WeekSelected.RowSource =
ActiveSheet.Range("a3:j26").address(external:=true )

or dropping the .select stuff

lstE2WeekSelected.RowSource _
= Sheets(grabdate).Range("a3:j26").address(external: =true)



Mick wrote:

Hi

Have a range of sheets:

12May
19May etc

In a userform I grab the correct sheet using:

Dim grabdate As String
'a drop down with names of the sheets
grabdate = cboE2WeekBeg.Value
Sheets(grabdate).Select

All works fine.

I then want a listbox to display a set range of cells but from the
selected worksheet.

Have tried
lstE2WeekSelected.RowSource = ActiveSheet.Range("a3:j26")

and

sheets(grabdate!a3:j26)

but both throw errors.

Any help appreciated

Mick


--

Dave Peterson


All times are GMT +1. The time now is 03:22 PM.

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