View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Surrealdogma Surrealdogma is offline
external usenet poster
 
Posts: 3
Default Using a macro to add a count and sum on a dynamic range

Hi all,
I am an macro / vba extreme newbie so please don't laugh. We receive a
comma delimited txt file and I am writing a macro to take care of a log of
the generic formatting issues we use on every file to get it ready for use.
As it stands right now I have a start date in column H and an end date in I
and the macro is already subtracting the two to give me a length in column J.
What I am trying to do is add a sum and a count after the last row in column
J. The problem is that every file will have a different number of records.

Following is the tail end section of my code, like I said earlier, I am very
new at this so please don't laugh. Thank you in advance for your help.

ActiveCell.FormulaR1C1 = "LOS"
Range("J6").Select
ActiveCell.FormulaR1C1 = "=RC[-1]-RC[-2]"
Range("J6").Select
Selection.NumberFormat = "General"
Selection.Copy
lr = Cells(Rows.Count, "a").End(xlUp).Row
Range("j6:j" & lr).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False