View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Find and Then Loop

Glad to help. I have seen the code you write in some of your other posts. You
should be trying this kind of stuff on your own. I know you can do it... any
time you want help though, just ask.
--
HTH...

Jim Thomlinson


"Paige" wrote:

Wow - you are AWSOME! Works like a charm, and I even understand what you
did...so little by little am learning. Thanks so much!!!

"Jim Thomlinson" wrote:

Give this a whirl...

Sub FindStuff()
Dim rngToSearch As Range
Dim rngToFind As Range
Dim rngFound As Range
Dim rng As Range
Dim wks As Worksheet

Set wks = ActiveSheet
With wks
Set rngToSearch = .Columns("A")
Set rngToFind = .Range(.Range("B2"), .Cells(Rows.Count, "B").End(xlUp))
End With

For Each rng In rngToFind
Set rngFound = rngToSearch.Find(What:=rng.Value, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then rng.Offset(0, 1).Value = "NA"
Next rng

End Sub

--
HTH...

Jim Thomlinson


"Paige" wrote:

I have 3 columns in a spreadsheet; data (which can be either numeric or
alpha) in Column A always starts in Row 11 and can go for 5, 10, or 10000
rows (i.e., it varies each time). Data (which can be either numeric or
alpha) in Column B always starts in row 2 and the last used cell can also
vary each time. Column C is blank. I need a macro that will do the
following:

1) Go to C2 and determine if Column A contains any instances of what is in
cell B2; if it does, then skip down to C3. If Column A does not contain any
instances of what is in cell B2, then enter 'N/A' in C2, and go on to C3.
2) Repeat this action through to the last used cell in Column B, at which
time, go on to the rest of the sub that follows.

Can someone please help me with this? Looping (and integrating last cell
code) is beyond my expertise at this time, but I'm trying to learn.
Thanks....Paige