Help Adding a Column with a formula

D

Dagonini

I am trying to insert a macro that will insert column in a file. The
column will be formatted to display an age.

I have so far:

Sub calculateage()



Columns("AU:AU").Select
ActiveCell.FormulaR1C1 = "=int((TODAY()-h1)/365.25)"
Selection.AutoFill Destination:=Columns("AU:AU"), Type:=xlFillDefault
Columns("AU:AU").Select




End Sub

The problem is the 3rd line is jamming up. I am trying to tell it to
apply the formula to the whole column from top to bottom of the
spreadsheet. Can you tell me what I have done wrong?
 
M

Mike Q.

Sub calculateage()

Range("AU1").Select
ActiveCell = "=int((TODAY()-h1)/365.25)"
Selection.AutoFill Destination:=Columns("AU:AU"), Type:=xlFillDefault

End Sub
 
F

FM

I have so far:
Sub calculateage()



Columns("AU:AU").Select
ActiveCell.FormulaR1C1 = "=int((TODAY()-h1)/365.25)"
Selection.AutoFill Destination:=Columns("AU:AU"), Type:=xlFillDefault
Columns("AU:AU").Select
End Sub

The problem is the 3rd line is jamming up. I am trying to tell it to
apply the formula to the whole column from top to bottom of the
spreadsheet. Can you tell me what I have done wrong?
Try:

Sub calculateage()

Range("AU1").Select ' <======== I CHANGED THIS
ActiveCell.FormulaR1C1 = "=int((TODAY()-h1)/365.25)"
Selection.AutoFill Destination:=Columns("AU:AU"), Type:=xlFillDefault
Columns("AU:AU").Select


End Sub


FM
 

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