Loop Statement

anotherphil

New Member
Joined
Jul 14, 2006
Messages
29
Hello Board:

In column A I have a series of references. In column B I have either "Project" or "Pursuit". I need code to identify all references associated with "Project" and return that reference in column C. This is what I have so far. Any ideas why this doesn't work?

WR Number Type Project/Pursuit
WR# 64 Pursuit
WR# 131 Project
WR# 172 Project
WR# 188 Pursuit
WR# 545 Project

[/code] Range("B2").Select
Dim Check
Check = True
Do
If ActiveCell = "Project" Then
ActiveCell.Offset(0, -1).Select
Dim WR
WR = ActiveCell
Range("C15").End(xlUp).Select
ActiveCell.Offset(1, 0).Select
ActiveCell = WR
Check = False
ElseIf ActiveCell = "Pursuit" Then
ActiveCell.Offset(1, 0).Select
Check = False
Else
Check = True
End If
Loop Until Check = True
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows
How doesn't it work?
 

anotherphil

New Member
Joined
Jul 14, 2006
Messages
29
It only posts the first reference. In the example above, C2 will be populated with WR# 131. I need WR# 172 and WR# 545 populated as well.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows
phil

Perhaps I'm missing something but couldn't you just use a formula for this?
 

anotherphil

New Member
Joined
Jul 14, 2006
Messages
29

ADVERTISEMENT

Because this is part of a larger code, I cannot use vlookup. That would be nice.
 

erkline

New Member
Joined
Mar 8, 2006
Messages
6
Not exactly sure what you are looking for but you could try the following.

public sub search()
dim a as range
set a=range("B2")
do until a.value = ""
if a.value = "Project" then
a.offset(0,1).value = true 'or whatever you want in col c
endif
set a = a.offset(1,0)
loop
 

Forum statistics

Threads
1,136,272
Messages
5,674,755
Members
419,525
Latest member
helensesc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top