ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formula in a Macro (https://www.excelbanter.com/excel-programming/380842-re-formula-macro.html)

Trevor Shuttleworth

Formula in a Macro
 
I assume you actually meant B1-A1 in cell C1 otherwise I think you'd get
circular references.

One way:

Range("C1").AutoFill _
Destination:=Range("C1:C" & Range("B1").End(xlDown).Row), _
Type:=xlFillDefault

Regards

Trevor


"Todd" wrote in message
...
I hope this is an easy question. I can't seem to figure it out.

I have a very simple spreadsheet that I am writing a macro for.
Basically,
I have written a formual in colum C that says, =B1 - C1, then copied it
down
all the rows of Column C.

A B C
21 55 34

Question is, when I apply this macro to spreadsheets of varying lengths,
it
doesn't stop at the last value. How do I specify the range so this will
work on spreadsheets of different sizes?






All times are GMT +1. The time now is 04:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com