LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Yet another Listbox question...

If you found that code via google, it's always better to sort by date--toss the
old, old stuff <vbg.

Pixel wrote:

Wow!! How about something like that.. It worked like a charm I'm
embarassed to tell you how many days I've played with this trying to
get it to work in fact it was even some of your code from previous
posts that I tried to integrate....

Thank you very much for your help

pixel

On Wed, 18 Jan 2006 15:07:36 -0600, Dave Peterson
wrote:

How about something like:

Option Explicit
Private Sub CommandButton1_Click()

Dim myCell As Range
Dim myRng As Range
Dim iCtr As Long

With Worksheets("sheet1")
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))
End With

If Trim(Me.TextBox1.Text) = "" Then
Beep
Exit Sub
End If

Me.ListBox1.Clear
For Each myCell In myRng.Cells
If LCase(myCell.Value) = LCase(Me.TextBox1.Text) Then
With Me.ListBox1
.AddItem myCell.Value
For iCtr = 1 To Me.ListBox1.ColumnCount - 1
.List(.ListCount - 1, iCtr) = myCell.Offset(0, iCtr).Value
Next iCtr
End With
End If
Next myCell

End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Me.ListBox1.ColumnCount = 4
End Sub


Pixel wrote:

Hi All
I have been trying to modify my code below so that each time
the value in Textbox1 is found, instead of sending the the data found
in columns (A,B,C,D) of that row to 4 different Textboxes and having
to press ok in the msgbox to find the next matching value, I would
like to send the entire row of 4 columns of every match to a listbox
as it cycles through the columnA looking for matches..

I have found several pieces of code in this news group that would help
but not being a very good at programming have failed to integrate them
with any success. Although I have been able to generate several
different error messages) :)

Private Sub CommandButton1_Click()
i = 2

Do While Cells(i, 1).Value < ""


If TextBox1.Value = Cells(i,1).Value Then

TextBox2.Value = Cells(i, 1).Value 'columnA
TextBox3.Value = Cells(i, 2).Value 'columnB
TextBox4.Value = Cells(i, 3).Value 'columnC
TextBox5.Value = Cells(i, 4).Value 'columnD

MsgBox "Next Record"

End If

i = i + 1
Loop


End Sub

Any help would be appreciated

Pixel


--

Dave Peterson
 
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
ListBox question LearningExcel Excel Programming 2 January 3rd 06 05:42 PM
ListBox Question LearningExcel Excel Worksheet Functions 0 December 30th 05 05:46 PM
Listbox Question Greg B[_4_] Excel Programming 0 March 9th 05 12:46 AM
ListBox question jacqui[_2_] Excel Programming 1 February 12th 04 02:23 AM
ListBox Question Randal W. Hozeski Excel Programming 7 December 20th 03 09:59 PM


All times are GMT +1. The time now is 10:12 PM.

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"