Thread: if & Loop
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default if & Loop

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim iLastRow As Long

With ActiveSheet

iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = iLastRow To 1 Step -1
If .Cells(i, TEST_COLUMN).Value = "Plan" Then
.Rows(i).Cut
.Rows(501).Insert
.Range(TEST_COLUMN & "500").Value = "New"
End If
Next i

End With

End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"steven.holloway" wrote in
message ...
I hope someone can help;

I am trying to write a macro to search column A in a worksheet for any
"Plan" entries. When it finds one I want it to cut the entire row the
entry
is on and insert the row at row 500, then rename the "Plan" in cell A500
to
"New". I want this procedure to repeat until all "Plan" rows have been
moved
and renamed.

By the way "Plan" entries are above row 500, so as each one is cut and
inserted at row 500, row 500 becomes 1 row less.

Also I want this to be sub operation within a current macro.

Can any one help?

Many thanks in advance
Steve