View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default inserting a formula next to populated cells

Sub Formulas()
Dim Rng As Range
Dim DateRange As Range
Set DateRange = Columns(1).SpecialCells(xlConstants,xlNumbers)
For Each Rng In DateRange
'If Not IsEmpty(Rng) Then
Rng.Range("B1").FormulaR1C1 = "My Formula"
'End If
Next Rng
End Sub


Depends on what is in Column A.

--
Regards,
Tom Ogilvy


"BRC" wrote in message
oups.com...
Rod thanks for the help. Your code works well but I think I wasn't
concise on my original post. The range of column A can change. It might
be a5-a6 or might be a5 - a210. So I can't hard code the range.
thanks again
BRC

Rod Gill wrote:
Hi,

Try:

Sub Formulas()
Dim Rng As Range
Dim DateRange As Range
Set DateRange = Range("A5:A14")
For Each Rng In DateRange
If Not IsEmpty(Rng) Then
Rng.Range("B1").FormulaR1C1 = "My Formula"
End If
Next Rng
End Sub

--

Rod Gill

"BRC" wrote in message
oups.com...
Hi All
I am looking for the most efficient way (in code) to insert a formula
in the cell next to one that is already populated. I. e. Cells a5-a14
have dates. I want to insert the same formula in cells b5-b14.
the range in col A changes. I have looked at help for autofill,
filldown etc but I not sure how to test for cell a(x) being greater
than "". Any suggestions would be appreciated.
Thanks BRC