Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default ListBox with 2 Columns

Hi
I have a listbox in my userform in which i would like to have two
columns show up from my find result. I am mixed as to the coding of
which i have the extract below.
Thks Kz

With grSearchRng
Set C = .Find(gvFindX, , goLookIn, goLookAt, goSearchOrder, ,
gbMatchCase)
If Not C Is Nothing Then
sFirstAddr = C.Address
Do
ufFind.LstFound.AddItem "'" & C.Worksheet.Name & "'!"
& C.Address
If IsNumeric(C.Value) Then
Select Case C.Column
Case 9, 10
error here-- ufFind.LstFound.List(.ListCount - 1, 1) = C.Value
Case Else
ufFind.LstFound.List(.ListCount - 1, 1) = Format(C.Value, "#,##0.00")

End Select
Else
ufFind.LstFound.List(.LstFound.ListCount - 1, 1) = C.Value

End If
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address < sFirstAddr
End If
End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default ListBox with 2 Columns

Kieranz explained on 9/9/2011 :
Hi
I have a listbox in my userform in which i would like to have two
columns show up from my find result. I am mixed as to the coding of
which i have the extract below.
Thks Kz

With grSearchRng
Set C = .Find(gvFindX, , goLookIn, goLookAt, goSearchOrder, ,
gbMatchCase)
If Not C Is Nothing Then
sFirstAddr = C.Address
Do
ufFind.LstFound.AddItem "'" & C.Worksheet.Name & "'!"
& C.Address
If IsNumeric(C.Value) Then
Select Case C.Column
Case 9, 10
error here-- ufFind.LstFound.List(.ListCount - 1, 1) = C.Value
Case Else
ufFind.LstFound.List(.ListCount - 1, 1) =
Format(C.Value, "#,##0.00")

End Select
Else
ufFind.LstFound.List(.LstFound.ListCount - 1, 1) =
C.Value

End If
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address < sFirstAddr
End If
End With


I suggest using an array to collect your data, THEN populate the
listbox from the array as this would be the quickest way.

You also need to set the ColumnCount property for the number of cols.

To add individual items you need to use the row/col index like this...

ListBox1.List(0, 0) = <col1 data
ListBox1.List(0, 1) = <col2 data

To 'dump' a 2D array into the listbox in one step...

ListBox1.List = myArray

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default ListBox with 2 Columns

Hi Gerry. Many thks for your reply. Being a newbie and lost on arrays
though i am reading about them
How do i dim the arrays and then apply to populate the listbox with 2
col.
Thks
K
Ps did not have internet connection.

I suggest using an array to collect your data, THEN populate the
listbox from the array as this would be the quickest way.

You also need to set the ColumnCount property for the number of cols.

To add individual items you need to use the row/col index like this...

* ListBox1.List(0, 0) = <col1 data
* ListBox1.List(0, 1) = <col2 data

To 'dump' a 2D array into the listbox in one step...

* ListBox1.List = myArray

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default ListBox with 2 Columns

Kieranz was thinking very hard :
How do i dim the arrays and then apply to populate the listbox with 2
col.


You'll need to provide more detailed info about your search process in
order for me to draft you a sample to run with.

Define usage for:
grSearchRng
gvFindX
goLookIn
goLookAt
goSearchOrder
ufFind
ufFind.LstFound

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


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
Can I freeze columns in a listbox Paul Excel Programming 0 March 19th 10 08:54 AM
Can't added two columns from one listbox to two columns in another Webtechie Excel Programming 4 August 21st 09 03:48 AM
Formating listbox columns ranswrt Excel Programming 8 September 5th 08 04:45 PM
format listbox columns ranswrt Excel Programming 1 April 28th 08 03:39 PM
Listbox Max Columns steve Excel Programming 2 March 13th 08 08:24 PM


All times are GMT +1. The time now is 09:49 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"