Macro to copy data when data is detected in another column(s).

R

Richard

I'm using excel 2007 to run a Macro. My macro inserts data in P2, Q2, R2, S2,
(my headers) P2, Q2, R2, S2 (my formulas). The macro works perfectly but I
would add on to it. On Columns A-O I always have data (I extract it from
another application), but depending on the day I might have 50 rows, 60 row,
100 rows, etc... I would like to add on to my macro to copy the formulas from
P2, Q2, R2, S2 down the row, say P3:p, Q3:Q, R3:R, S3:S; until no more data
is detected from columns A-O. If this helps, on certain columns (C and O) I
have the exact same data.
 
P

Per Jessen

Hi

First, we calculate last row, then we fill down the formulas in row
2....

LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("P2:S" & LastRow).FillDown


Regards,
Per
 
G

Gord Dibben

Assuming column C will be filled at least as far down as other columns in
A:O

Sub Auto_Fill()
Dim lRow As Long
With ActiveSheet
lRow = .Range("C" & Rows.Count).End(xlUp).Row
.Range("P2:S" & lRow).FillDown
End With
End Sub

BTW...........I am also assuming that your headers are P1:S1 and you have a
typo in your description.


Gord Dibben MS Excel MVP
 

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