View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mat P:son[_2_] Mat P:son[_2_] is offline
external usenet poster
 
Posts: 97
Default Formula needs to reference anchored relative cell

Ah, okay, well what about this then (I've been very explicit about things in
the VBA code, just to make sure I'm clear enough, but if I'm not then don't
hesitate to ask me again):

==============

Private Sub LetsFillInTheBlanks()
' Get the last cell of the A column
' (requires data to be contiguous!)
Dim r As Range
Set r = Range("A1").End(xlDown)

' Get an absolute cell reference in
' RC notation (check AddressLocal()
' in the VBA Help for alternatives)
Dim s As String
s = r.AddressLocal(True, True, xlR1C1)

' Set the formulae for all of col B
Dim i As Long
For i = 1 To r.Row
Cells(i, 2).FormulaR1C1 = "=RC[-1] - " & s
Next i
End Sub

==============

"mkerstei" wrote:


Right, I understand the use of
Range("A1").End(xlDown)
But I do not know how to put that into an equation that will be copied
down the the bottom of the column.
right now it would be

Range("b2").Select
ActiveCell.FormulaR1C1 = "=RC[-3]-Total

Where total would be the Range("A1").End(xlDown)
I know this is totally simple, but I just don't know VBA very well.
How do I put a macro formula into an excel formula?


--
mkerstei
------------------------------------------------------------------------
mkerstei's Profile: http://www.excelforum.com/member.php...o&userid=25688
View this thread: http://www.excelforum.com/showthread...hreadid=549058