LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Using 'Find' and 'FindNext' in vba

I have been struggling to write a short piece of code to do the following

Sheets("Invoices").Range("a:a") contains Supplier Names
Sheets("Invoices").Range("c:c") contains Invoice Numbers

I have created a userform to to display the invoice details after specifying
the above details
i.e. ComboBox1 contains a Supplier Name and
TextBox3 contains the invoice Number
Then I click on a command button with the following code but it only
displays details of the first occurance of the Supplier Name

Comments, suggestions etc very greatly appreciated

Regards and TIA
Jim Burton
.................................................. ..................
Private Sub CommandButton2_Click()

Dim InvMo As Integer
SuppName = ComboBox1
InvNo = Format(TextBox2, "####")

With Worksheets("Invoices")
Set C = .Range("a:a").Find(SuppName, LookIn:=xlValues)

If Not C Is Nothing And .Cells(C.Row, 3) < InvNo Then firstAddress =
C.Address
Do
Set C = .Range("a:a").FindNext(C)
Loop While Not C Is Nothing And .Cells(C.Row, 3) < InvNo And
C.Address < firstAddress

TextBox1 = .Cells(C.Row, 2)
TextBox3 = .Cells(C.Row, 4)
End With

End Sub
.................................................. .........


I have tried numerous pieces of cod and they all stop at the 1st occurence


 
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
Findnext Noemi Excel Discussion (Misc queries) 1 December 12th 05 11:23 AM
Find Findnext in selected range looloo[_2_] Excel Programming 2 January 25th 05 06:51 PM
Find, Findnext VBA Loop SMS - John Howard Excel Programming 5 November 13th 04 03:19 AM
FindNext John Keturi Excel Programming 1 October 16th 04 01:56 PM
Find...FindNext Problem mtsark Excel Programming 4 August 19th 04 04:09 PM


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