Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default populate a list box with different data

hi, i have a list box on a userform that displays dta from a part of my
spreadsheet. the list will have a different number of rows at different
times but always the same amount of columns. I have worked out that
there will never be more then 200 rows to display so i am currently
using

private sub userform activate
listbox1.columncount = 20
listbox1.list = range("a1:u200".value
end sub

this ensure i get all the dat into the listbox. can i make it smarter
so the list box only displays rows with data in rather then all 200.
Although this method seems to work sometime whne i run the program i am
unable to select certain rows within the listbox. i.e i may have 20
rows in the listbox and i can only highlight 17 of them.

regards

john

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default populate a list box with different data

John,

Try this

Private Sub userform_activate()
ListBox1.ColumnCount = 20
ListBox1.List = Range("A1:U" & Application.CountA(Range("A:A"))).Value
End Sub


--
HTH

Bob Phillips

wrote in message
oups.com...
hi, i have a list box on a userform that displays dta from a part of my
spreadsheet. the list will have a different number of rows at different
times but always the same amount of columns. I have worked out that
there will never be more then 200 rows to display so i am currently
using

private sub userform activate
listbox1.columncount = 20
listbox1.list = range("a1:u200".value
end sub

this ensure i get all the dat into the listbox. can i make it smarter
so the list box only displays rows with data in rather then all 200.
Although this method seems to work sometime whne i run the program i am
unable to select certain rows within the listbox. i.e i may have 20
rows in the listbox and i can only highlight 17 of them.

regards

john



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default populate a list box with different data

bob,

thanks that works great,
i am still getting the problem of not being able to select certain rows
within the listbox, the list box is on userform2 and is accessed from
userform1, i can go back and forth through the forms and on about the
third time this happens, any ideas

john

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default populate a list box with different data

Sure, your approach is probably screwed up. when you show useform1 and have
it show userform2 and userform2 then shows userform1 and so on, the original
userform1 has never unloaded since its event hasn't terminated.

In userform1 you should have

Private Sub Commandbutton1_Click()
me.hide
userform2.show
me.show
end Sub

In userform2, the button should unload userform2.

I suspect you have


In Userform1

Private Sub commandButton1_Click()
unload me
Userform2.show
End sub

in Userform2

Private Sub Commandbutton1_Click
unload me
Userform1.Show
End sub

Userform1 can't terminate until userform2 terminates. Userform2 can't
terminate until userform1 terminates. then things start to get screwed up.

--
Regards,
Tom Ogilvy



wrote in message
oups.com...
bob,

thanks that works great,
i am still getting the problem of not being able to select certain rows
within the listbox, the list box is on userform2 and is accessed from
userform1, i can go back and forth through the forms and on about the
third time this happens, any ideas

john



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default populate a list box with different data

tom,

this is how i have it

code from userform1

Private Sub CommandButton1_Click()
call results
end sub


then from the results sub

sub results ()

unload userform1

various code

userform2.show
end sub

then from userform2

Private Sub CommandButton1_Click()

call searchagain ()

end sub

sub searchagain ()

unload userform2

various code

userform1.show

end sub ()

i have check earlier from another posting that this method was ok what
do you think

john



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default populate a list box with different data

i have just noticed that when i go to two the userform2 a second time
if the program brings up a row of data that appeared the last time i
loaded userform2, which it can sometimes its that data that i cannot
select. any ideas

john

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default populate a list box with different data

Your doing exactly what I said causes problems.

I already gave you an idea - but if you don't feel you are having problems
or you don't feel that is the problem, then the suggestion can be ignored.

--
Regards,
Tom Ogilvy



wrote in message
oups.com...
i have just noticed that when i go to two the userform2 a second time
if the program brings up a row of data that appeared the last time i
loaded userform2, which it can sometimes its that data that i cannot
select. any ideas

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
How can I populate a drop down list from Data Validation? Brian Excel Discussion (Misc queries) 1 August 17th 09 05:32 PM
Pulling data from other wb based on data to populate dropdown list Suzann Excel Discussion (Misc queries) 0 April 23rd 09 04:29 PM
Populate a column of data with a formula using a drop down list nafflerbach Excel Discussion (Misc queries) 1 May 24th 07 12:20 PM
populate data valadation list by criteria John in Surrey Excel Worksheet Functions 1 November 9th 05 10:07 AM
I wish to automatically populate cells with list data when a item. juggernaught Excel Discussion (Misc queries) 2 February 23rd 05 09:49 PM


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

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

About Us

"It's about Microsoft Excel"