Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Find and Then Loop

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Find and Then Loop

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Find and Then Loop

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Find and Then Loop

Thanks, Jim. I'm a little (well, more than a little) fuzzy on loops and many
finer points of coding. I try to look stuff up both here and in my numerous
books and do myself, but after awhile, when the headache hits, I know it's
time to ask for assistance. One of these near weekends I'll just have to sit
down with my books and really learn some of the important things missed the
first time around. Your assistance, and that of everyone else's on this
website is just invaluable, and I thank you again for that! Have a great
evening...Paige

"Jim Thomlinson" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Find and Then Loop

You don't give yourself enough credit. If you understand that code you are
probably further along than you think. You understand worksheet objects,
range objects and get the idea of using a for next loop to traverse a
collection of objects... That is lots and more than most.
--
HTH...

Jim Thomlinson


"Paige" wrote:

Thanks, Jim. I'm a little (well, more than a little) fuzzy on loops and many
finer points of coding. I try to look stuff up both here and in my numerous
books and do myself, but after awhile, when the headache hits, I know it's
time to ask for assistance. One of these near weekends I'll just have to sit
down with my books and really learn some of the important things missed the
first time around. Your assistance, and that of everyone else's on this
website is just invaluable, and I thank you again for that! Have a great
evening...Paige

"Jim Thomlinson" wrote:

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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Find and Then Loop

I'm starting a similar project however this is a "running total" spreadsheet.
I will be comparing the data in "myrange" with several different columns
that will be added to each week.

This week the comparison would be with "D" and "P" next week there will be
another column. All columns will have the title "Route Number(s)".

Here is what I have so far:

With lastperiod

'Find the last used column
myrange = ActiveSheet.UsedRange.Columns.Count
ActiveSheet.Cells(1, myrange + 2).Select

'paste the info
ActiveSheet.Paste

'start checking for duplicate route numbers
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 = .Cells(myrange + 2)
Set rngToFind =

"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

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
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Loop and Find Chad[_12_] Excel Programming 3 April 8th 06 07:20 PM
Find & loop in VBA Noemi Excel Discussion (Misc queries) 3 January 25th 06 03:39 AM
VB can't find my For loop??? Goobies Excel Programming 4 January 24th 06 06:31 PM
Find and loop John Excel Programming 5 September 20th 05 06:47 PM


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