Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default List Box Visible Rows Only

having some (a lot) of trouble with this.
I know it can be done and I think I've exausted my searches (and my
patience).

I have a list box on a UserForm

I need to fill the list box with a filtered range of data on the active
worksheet.
Header row is row 5.
Data starts on row 6
For example, after a filter, only rows (5), 6, 8 & 10 are visible.
How can I populate the list box with the data for columns A, B & C
with only rows 6, 8 & 10??

TIA,
John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default List Box Visible Rows Only

Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
Next
End if
--
Regards,
Tom Ogilvy

"John Wilson" wrote in message
...
having some (a lot) of trouble with this.
I know it can be done and I think I've exausted my searches (and my
patience).

I have a list box on a UserForm

I need to fill the list box with a filtered range of data on the active
worksheet.
Header row is row 5.
Data starts on row 6
For example, after a filter, only rows (5), 6, 8 & 10 are visible.
How can I populate the list box with the data for columns A, B & C
with only rows 6, 8 & 10??

TIA,
John



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default List Box Visible Rows Only

Tom,

A had actually found (and tried) that code you supplied in the
Google archives.
What I cant do with it is modify it to include three columns.
My list box is three columns wide.
I wanted to populate the List box with what's in Columns A thru C
of the visible rows only??

John


Tom Ogilvy wrote:

Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
Next
End if
--
Regards,
Tom Ogilvy

"John Wilson" wrote in message
...
having some (a lot) of trouble with this.
I know it can be done and I think I've exausted my searches (and my
patience).

I have a list box on a UserForm

I need to fill the list box with a filtered range of data on the active
worksheet.
Header row is row 5.
Data starts on row 6
For example, after a filter, only rows (5), 6, 8 & 10 are visible.
How can I populate the list box with the data for columns A, B & C
with only rows 6, 8 & 10??

TIA,
John


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default List Box Visible Rows Only

Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
listbox1.List(Listbox1.Listcount-1,1) = cell.offset(0,1)
listbox1.List(Listbox1.Listcount-1,2) = cell.Offset(0,2)
Next
End if


I believe you can also do this:

Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
' haven't tried this, but this is how I understand help
listbox1.column(1) = cell.offset(0,1)
listbox1.column(2) = cell.Offset(0,2)
Next
End if
--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
Next
End if
--
Regards,
Tom Ogilvy

"John Wilson" wrote in message
...
having some (a lot) of trouble with this.
I know it can be done and I think I've exausted my searches (and my
patience).

I have a list box on a UserForm

I need to fill the list box with a filtered range of data on the active
worksheet.
Header row is row 5.
Data starts on row 6
For example, after a filter, only rows (5), 6, 8 & 10 are visible.
How can I populate the list box with the data for columns A, B & C
with only rows 6, 8 & 10??

TIA,
John





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default List Box Visible Rows Only

Tom,

The second example didn't work.....
"Could not set the Column property. Invalid property array index"
(Win 98 / Excel 2000 SR-3)
But the first one worked like a charm.

THANK YOU!!!

John


Tom Ogilvy wrote:

Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
listbox1.List(Listbox1.Listcount-1,1) = cell.offset(0,1)
listbox1.List(Listbox1.Listcount-1,2) = cell.Offset(0,2)
Next
End if

I believe you can also do this:

Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
' haven't tried this, but this is how I understand help
listbox1.column(1) = cell.offset(0,1)
listbox1.column(2) = cell.Offset(0,2)
Next
End if
--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
Next
End if
--
Regards,
Tom Ogilvy

"John Wilson" wrote in message
...
having some (a lot) of trouble with this.
I know it can be done and I think I've exausted my searches (and my
patience).

I have a list box on a UserForm

I need to fill the list box with a filtered range of data on the active
worksheet.
Header row is row 5.
Data starts on row 6
For example, after a filter, only rows (5), 6, 8 & 10 are visible.
How can I populate the list box with the data for columns A, B & C
with only rows 6, 8 & 10??

TIA,
John






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default List Box Visible Rows Only

Thanks for testing it. Been meaning to for a while now, but haven't gotten
around to it. I will have to re-read the help and work out the additional
argument needed.

--
Regards,
Tom Ogilvy

"John Wilson" wrote in message
...
Tom,

The second example didn't work.....
"Could not set the Column property. Invalid property array index"
(Win 98 / Excel 2000 SR-3)
But the first one worked like a charm.

THANK YOU!!!

John


Tom Ogilvy wrote:

Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
listbox1.List(Listbox1.Listcount-1,1) = cell.offset(0,1)
listbox1.List(Listbox1.Listcount-1,2) = cell.Offset(0,2)
Next
End if

I believe you can also do this:

Dim rng as Range
On Error Resume Next
set rng =
Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
' haven't tried this, but this is how I understand help
listbox1.column(1) = cell.offset(0,1)
listbox1.column(2) = cell.Offset(0,2)
Next
End if
--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Dim rng as Range
On Error Resume Next
set rng =

Range(Cells(6,1),Cells(rows.count,1).End(xlup)).Sp ecialCells(xlVisible)
On Error goto 0
if not rng is nothing then
for each cell in rng
listbox1.AddItem cell.Value
Next
End if
--
Regards,
Tom Ogilvy

"John Wilson" wrote in message
...
having some (a lot) of trouble with this.
I know it can be done and I think I've exausted my searches (and my
patience).

I have a list box on a UserForm

I need to fill the list box with a filtered range of data on the

active
worksheet.
Header row is row 5.
Data starts on row 6
For example, after a filter, only rows (5), 6, 8 & 10 are visible.
How can I populate the list box with the data for columns A, B & C
with only rows 6, 8 & 10??

TIA,
John






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdown List - list item endings not visible if column too narrow AK9955 Excel Discussion (Misc queries) 2 April 27th 07 09:02 AM
Hide a visible rows Wanna Learn Excel Discussion (Misc queries) 5 February 15th 07 08:23 PM
Using COUNTIF with visible rows only Dr Happy Excel Worksheet Functions 2 December 7th 05 03:45 PM
How to plot only visible autofiltered rows in a data list Craig Charts and Charting in Excel 1 June 28th 05 08:38 PM
AutoFilter - which rows are currently visible? Bjørnar Hartviksen Excel Programming 2 October 6th 03 12:01 AM


All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"