View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
pete pete is offline
external usenet poster
 
Posts: 88
Default Loop Statment help!

Can some one tell me how to set up this code as a loop
statment so I only have to preform the funtion once and
the code will preform until the last row of my range has
been moved.

here is the code I have.

Sub MoveUSDown()

Application.ScreenUpdating = False


ActiveCell.Name = "MoveUS1"
Cells.Find(What:="Totals in USD:",
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False).Activate
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveCell.Name = "MoveUS2"
Range("MoveUS1:MoveUS2").Select
Selection.Cut Destination:=ActiveCell.Offset(1, 0)
Range("W3").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-21]=RC[3],""Y"",IF(RC
[3]="""",""A"",""""))"
Range("W3").Select
Selection.AutoFill Destination:=Range("W3:W219")
Range("MoveUS2").Select
ActiveWorkbook.Names("MoveUS2").Delete
Range("MoveUS1").Select
ActiveWorkbook.Names("MoveUS1").Delete
ActiveCell.Offset(-1, -3).Range("A1").Select
Selection.ClearContents

End Sub

In my code I put a Y,A or blank in the cell across from my
list to let me know which cells have to be moved next. If
we don't need that please feel free to take it out.

Thanks for any help.
Pete