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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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.
 
Upvote 0
phil

Perhaps I'm missing something but couldn't you just use a formula for this?
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,575
Messages
6,120,342
Members
448,956
Latest member
Adamsxl

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
Back
Top