Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Listbox value return from search


I am trying to create a UserForm that will search a spreadsheet and
return multiple values to a listbox. For example the program below
searchs column E for the Value in textbox1.

How do I then return the value from column A of the same row to
listbox1?
Thanks,
M

Private Sub CommandButton7_Click()
With Worksheets(1).Range("e:e")
Set e = .Find(TextBox1, LookIn:=xlValues)
If Not e Is Nothing Then
firstAddress = e.Address
Do
"Write value from column A in same row to ListBox1"
Set e = .FindNext(e)
Loop While Not e Is Nothing And e.Address < firstAddress
End If
End With
End Sub


--
Mcat
------------------------------------------------------------------------
Mcat's Profile: http://www.excelforum.com/member.php...o&userid=29234
View this thread: http://www.excelforum.com/showthread...hreadid=489567

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Listbox value return from search

Assuming CommandButton7 is on the same userform as ListBox1 and TextBox1
try:

Private Sub CommandButton7_Click()
Dim e As Range
Dim firstAddress As String
With Worksheets(1).Range("e:e")
Set e = .Find(Me.TextBox1.Value, LookIn:=xlValues)
If Not e Is Nothing Then
firstAddress = e.Address
Do
Me.ListBox1.AddItem e.Offset(0, -4).Value
Set e = .FindNext(e)
Loop While Not e Is Nothing And e.Address < firstAddress
End If
End With
End Sub

Hope this helps
Rowan

Mcat wrote:
I am trying to create a UserForm that will search a spreadsheet and
return multiple values to a listbox. For example the program below
searchs column E for the Value in textbox1.

How do I then return the value from column A of the same row to
listbox1?
Thanks,
M

Private Sub CommandButton7_Click()
With Worksheets(1).Range("e:e")
Set e = .Find(TextBox1, LookIn:=xlValues)
If Not e Is Nothing Then
firstAddress = e.Address
Do
"Write value from column A in same row to ListBox1"
Set e = .FindNext(e)
Loop While Not e Is Nothing And e.Address < firstAddress
End If
End With
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Listbox value return from search


B-E-utiful

Thanks!


--
Mcat
------------------------------------------------------------------------
Mcat's Profile: http://www.excelforum.com/member.php...o&userid=29234
View this thread: http://www.excelforum.com/showthread...hreadid=489567

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Listbox value return from search

You're welcome.

Mcat wrote:
B-E-utiful

Thanks!


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
Select Multiple Items and return value for Dropdown or listbox kookie Excel Discussion (Misc queries) 4 January 19th 09 10:18 PM
Search and return John21 Excel Worksheet Functions 2 August 7th 06 06:00 PM
How do I return the unique entries from a column to a listbox Dave Mc Excel Worksheet Functions 4 February 9th 05 08:02 AM
Return Items from Listbox Tod Excel Programming 1 January 18th 05 02:22 AM
Search and return value index[_7_] Excel Programming 4 November 30th 03 10:33 PM


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