A
Astello
I have a macro in excel that fills a formula in the first cell in a
column, then copies that formula and fills it into the rest of the
column. There is placeholder data in this column, so that the formula
will only be copied to a certain amount of cells. My code looks like
this:
Range("P2").Select
ActiveCell.FormulaR1C1 = "=Miles(RC[-10],RC[-5])"
Range("P2").Select
Selection.Copy
Range("P2").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Range("P2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Now the code works fine, but for some reason it pastes the formula well
past the data that is in the column (ex. if data is in rows 1-42, the
formula gets copied to rows 1-112) which gives me a bunch of "#N/A"s,
which causes problems when I try to sum up these values. Any idea why
this is happening? I thought putting in "xlDown" was supposed to
prevent this problem...
column, then copies that formula and fills it into the rest of the
column. There is placeholder data in this column, so that the formula
will only be copied to a certain amount of cells. My code looks like
this:
Range("P2").Select
ActiveCell.FormulaR1C1 = "=Miles(RC[-10],RC[-5])"
Range("P2").Select
Selection.Copy
Range("P2").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Range("P2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Now the code works fine, but for some reason it pastes the formula well
past the data that is in the column (ex. if data is in rows 1-42, the
formula gets copied to rows 1-112) which gives me a bunch of "#N/A"s,
which causes problems when I try to sum up these values. Any idea why
this is happening? I thought putting in "xlDown" was supposed to
prevent this problem...