Row spec

L

LiAD

Hello again,

Another small simple question for someone that knows how.

How do i adapt this code in order to stop copying at row 109 maximum? So
its max copying range is 11 to 109 inclusive.

LastRow = Range("E" & Rows.Count).End(xlUp).Row
Range("P11:AC11").AutoFill Destination:=Range("P11:AC" & LastRow),
Type:=xlFillDefault

Thanks
LiAD
 
P

Patrick Molloy

see below

LiAD said:
Hello again,

Another small simple question for someone that knows how.

How do i adapt this code in order to stop copying at row 109 maximum? So
its max copying range is 11 to 109 inclusive.

LastRow = Range("E" & Rows.Count).End(xlUp).Row
If LastRow>109 then lastRow = 109
 
M

Mauro Gamberini

Try

LastRow = Range("E" & Rows.Count).End(xlUp).Row
If LastRow > 109 then
LastRow = 109
End If
Range("P11:AC11").AutoFill Destination:=Range("P11:AC" & LastRow),
Type:=xlFillDefault

--
 
L

LiAD

OK,

Thanks for this. It does stop it at row 109, which I thought would have
solved my problem, but it doesn't for some reason.

I have a table of values which are copy pasted from other sources using a
macro. I have only data in cells C10-O15, the rest until row 109 are empty,
no formulas either.

When i run this macro it is copying the formulas down in all cells from 11
to 109, even the ones with an empty E cell. Even if i hit delete in the E
cells that are empty before i run the macro it still doesnt work.

Do you know why this would be or how I would fix it?

Sub CopyFormulas()

Sheets("1").Select

lastRow = Range("E" & Rows.Count).End(xlUp).Row
If lastRow > 109 Then lastRow = 109
Range("P11:AC11").AutoFill Destination:=Range("P11:AC" & lastRow),
Type:=xlFillDefault

End Sub

Thanks
LiAD
 
L

LiAD

Thanks.

Tried and works but I get the same issue as my reply to Patrick with the
copying formulas into rows where cell E is empty.

Thanks
 

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