View Single Post
  #19   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Finding last cell and insert line

Sub AddFormulas()
Dim rng as Range
Set rng = Cells(1, 1).End(xlDown).Offset(1, 0)
rng.Range( _
"A1,C1,F1:J1").FormulaR1C1 = "=Sum(R2C:R[-1]C)"
rng.EntireRow.Insert
End Sub

the original worked fine for me. This one inserts a line above the
formulas. It worked fine for me as well.

--
Regards,
Tom Ogilvy



"Matt" wrote in message
...
I am trying this and getting a 400 error...not really sure what that means?

"Tom Ogilvy" wrote:

Assuming the column will never be blank or have less than 2 rows, and
headers are in row1.

Sub AddFormulas()
Cells(1,1).End(xldown).offset(1,0).Range( _
"A1,C1,F1:J1").formulaR1C1 = "=Sum(R2C:R[-1]C)"
End Sub

adds formulas in column A, C, F through J. Adjust to suit.
--
Regards,
Tom Ogilvy

"Matt" wrote in message
...
Hello,

I want to write a program that will search down a column to find the
first
empty cell, insert a row at that point, and then perform sums for
certain
columns. Also, I want to create line formats for each column. The first
empty
cell occurrence will be variable, but the columns will be
fixed....Thanks!