subtracting columns in a macro

  • Thread starter Thread starter Vel
  • Start date Start date
V

Vel

I would like to subtract one column from another in the
macro I am creating. Can someone tell me how to do that
when the number of rows in the spreadsheet will always
vary?
Thanks so much!
 
Hi Vel
one simple idea: Subtract the whole columns from each other:
application.WorksheetFunction.Sum(range("A:A")) -
application.WorksheetFunction.Sum(range("B:B"))

Frank
 
Assume you want to subtract Column A from column B and Column A will
determine the number of cells and first value is in A1

Dim rng as Range
Set rng = Range(Cells(1,1),Cells(rows.count,1).End(xlup))
rng.copy
Range("B1").Pastespecial paste:=xlPasteValues, _
Operation:=xlPasteSpecialOperationSubtract

Might want to post programming question in

news://msnews.microsoft.com/microsoft.public.excel.programming
 
Back
Top