Copy formula down to last active cell

cr2289

New Member
Joined
Jul 21, 2016
Messages
28
Office Version
  1. 365
Platform
  1. Windows
I have a simple formula, D2/C2 = Percentage. What is the VBA to copy the formula down to the last active cell in the column?
 
last active cell in the column
Please describe exactly what you mean by the above? and what cell are you putting the original formula in?
Can you also post the actual formula you are putting in the cell
 
Upvote 0
Suppose you want to put the results in column a starting from row 2

VBA Code:
Sub CopyFormulaDown()
    Dim LastRow As Long
    LastRow = Cells(Rows.Count, "D").End(xlUp).Row
    
    Range("a2").AutoFill Destination:=Range("a2:a" & LastRow)
    
    'Convert cell range to percentage format
    Range("A2:A" & LastRow).Style = "Percent"
End Sub
 
Upvote 0
What makes you think it is a Style (I would think if anything along those lines it would be a numberformat) and not a Formula as the OP has stated?
 
Upvote 0
Please describe exactly what you mean by the above? and what cell are you putting the original formula in?
Can you also post the actual formula you are putting in the cell
Hi Mark! The formula will go in Column E and copy down to the last active cell in the column. The formula is C2/D2 = Percentage in Column E.
 
Upvote 0
What exactly do you mean by last Active cell in the column (what exactly are you basing the last Active cell on)? and C2/D2 = Percentage isn't a valid formula.

Do you mean for the formula
Excel Formula:
=C2/D2
then format the cells as a percentage?
 
Last edited:
Upvote 0
Do you mean for the formula
=C2/D2then format the cells as a percentage?
Assuming the above is what you actually mean and using Column C to determine the last row as you should have data in that column try the code below...

VBA Code:
Sub cr2289A()
    With Range("E2:E" & Range("C" & Rows.Count).End(xlUp).Row)
        .Formula = "=C2/D2"
        .NumberFormat = "0.00%"
    End With
End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top