column loop problem??

G

Guest

I have a spreadsheet with 3 columns. Column 1 will have various text and
will each cell will have something in it. Column two has a header of "Use
Record", this column will have values of 1, 0 or it will be empty.

What I want to do is find Use "Record" and then work my way down the column
and if the value = 0 then make column 1 text = "Dropped" then bold the whole
row.

How do I do the loop since column 2 could have a blank cell and there still
could be rows in the spreasheet?

Thanks
Mike

Col1 Use Record Col2
a 1
b 0
c
d 0
e 0
f
g 1
h
 
T

Tom Ogilvy

Dim rng as Range, cell as Range
set rng = Range(cells(1,2),Cells(rows.count,2).end(xlup))
for each cell in rng

Change the 1 in 1,2 to indicate the row you want to start in.

Or if that is what you mean - that you want to find the word Record in
column 2

Dim rng1 as Range, rng as Range, cell as Range
set rng1 = Columns(2).find("Record", Lookat:=xlPart, Lookin:=xlValues)
if not rng1 is nothing then
set rng = Range(rng1,Cells(rows.count,2).end(xlup))
for each cell in rng
 
G

Guest

Thanks for the reply. I'll try and figure out what it's doing.

Here is what I had. I just stuck the loop 100 times to get it moving.


Sub Use_Record_Drop()
'Find "Use Record"
Cells.Find(What:="Use Record", After:=ActiveCell, LookIn:=xlFormulas, _
Lookat:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Activate
Dim x
For x = 1 To 100
If ActiveCell.Text = "0" Then
ActiveCell.Offset(0, -1).Activate
ActiveCell.Value = "Dropped"

ActiveCell.Offset(0, 1).Activate
'Move cursor down
ActiveCell.Offset(1, 0).Activate
Else
'Move cursor down
ActiveCell.Offset(1, 0).Activate
End If
Next
 

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