View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default repeating a macro for a specified range

something like this to play with.

for i=7 to 10
if ucase(cells(i,"l"))="Y" then _
range(cells(i,"e"),cells(i+21,"e")).cut destination:=cells(i-1,"e")
next i

--
Don Guillett
SalesAid Software

"Willip" wrote in message
ups.com...
Hi

Im sure someone can help me with this. I have created an input box for
some data pasted in from another program. Some of these lines are
headers and page breaks which I want to remove , I have got an if
statement to flag each line with a Y if it needs deleting and for one
line I can use

If Range("L6") = "Y" Then

Range("E7:E28").Select
Range("E7:E28").Cut Destination:=Range("E6:E27")

End If

the next one would be

If Range("L7") = "Y" Then

Range("E8:E28").Select
Range("E8:E28").Cut Destination:=Range("E7:E27")


End If

etc


Is there a way of getting the macro to run automatically for all 20
lines, rather then just having 20 or so of the above

thanks in advance Will