Excel VBA - Looking up Values in every cell until match found

K

kevinmawn

Hi!
I am having difficulties writing the proper macro for the followin
data:

321456 _ 05/15/04 _ M-INV
654896 _ 01/08/04 _ M-REG
265434 _ 06/08/04 _ PROD
... _ ... _ ...
135658 _ 07/11/04 _ M-CAP

Where _ Separates each columns

I extract data from a database and I get six columns, the problem is
never know what their order is and they are not tagged. I'm trying t
write a macro that would look up the value of the cell A1 throug
A(LastRow) then jump to B1 through B(LastRow) Then C1... until th
value of the cell = "PROD".

Here's my attempt:

***********************************
Sub Report()

' Finding the Last Row of Data
With Sheets("Raw Data")
LastRow = Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
End With
Range("H2").Select
Selection = LastRow


Do
j = 0
Do
i = 0
j = j + 1
Do
i = i + 1
Loop Until i = LastRow
Loop Until j = 6
Loop Until "PROD" = Mid(Cells(i, j).Value, 1)

' Display in which row "PROD" was found
Range("H1").Select
Selection = j

End Sub
***********************************

For some reason, It never meets the condition:
Loop Until "PROD" = Mid(Cells(i, j).Value, 1).


Thanks for your time!

Kevi
 
D

Don Guillett

If you are trying to find the address of "PROD", you might have better
success by looking in VBA Help for FIND. There is a good example there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top