![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 117
|
Private Sub CommandButton1_Click()
For Each s In Worksheets("sheet2").range("a1:a100") If s.Value = ListBox1.Value Then x = s.Offset(0, 1).Value Sheets(x).Activate ListBox2.rowsource = Sheets(x).range("a1:i10000") End If Next s exit sub This code finds a sheet from a selection in listbox1 when the user clicks the commandbutton. Why cant I figure out why I cant get the range A1:I10000 of that sheet to display in listbox2 ???? Please help |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 50,319
|
Todd,
Off topic, more or less anyway. A ListBox housing 10,000 items amazes me. How do you use it? Aladin |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Posts: 117
|
Its actually supposed to read range(a1:i100).
Any ideas? |
|
|
|
|
|
#4 |
|
New Member
Join Date: Aug 2011
Posts: 7
|
I really would like that someone had replied to you, because I'm looking for the exact same thing
Will continue to search the forum |
|
|
|
|
|
#5 |
|
MrExcel MVP
Moderator Join Date: Jun 2002
Location: UK 51°34'30.38"N, 0°24'59.13"W
Posts: 51,374
|
Try like this
Code:
UserForm1.ListBox1.RowSource = Worksheets("sheet1").Range("A1:I100").Address(external:=True)
__________________
HTH, Peter Please test any code on a copy of your workbook. |
|
|
|
|
|
#6 |
|
New Member
Join Date: Aug 2011
Posts: 7
|
Wow!
Thanks very much! |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2004
Location: Yaren
Posts: 58,386
|
You can also use List.
Code:
Listbox1.List = Sheets(x).Range("A1:I100").Value
Doesn't link the range and listbox directly.
__________________
If posting code please use code tags. |
|
|
|
|
|
#8 |
|
New Member
Join Date: Aug 2011
Posts: 7
|
Thanks!
So, if I use list, when the data changes in the sheet, it will not change in the ListBox? That has some advantages for what I'm trying to do. |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Apr 2004
Location: Yaren
Posts: 58,386
|
That's right.
The obvious disadvantage is that you'll need to take care of the transfer to the worksheet yourself. Mind you that could be an advantage as it'll give you more control.
__________________
If posting code please use code tags. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|