Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA code to calculate the difference between rows
Desmond,
The following code subtracts the cells in row 2 from the cells in row 1 and places the results in an array: Sub Difference() Dim i As Integer Dim dResult(1 To 10) As Double For i = 1 To 10 dResult(i) = Cells(1, i).Value - Cells(2, i).Value Next i End Sub -- John Green - Excel MVP Sydney Australia "Desmond" wrote in message ... Hello, I have two rows of numbers in cells. I need the VBA code that will subtract each cell value in one line from the cell in the same column in the other line. I created a macro that subtracts the first cell and copies across the row, but with the worksheet protected this does not work. I tried a recorded macro subtracting each cell separately, and this seems to work. So I believe I need a loop structure, and I am having trouble with this. Your assistance would be appreciated. I know little of programming, so your help would be valuable Thanks desmond |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro code to hide rows and not calculate hidden rows | Excel Discussion (Misc queries) | |||
how to calculate time difference in hh:mm:ss | Excel Discussion (Misc queries) | |||
Calculate the difference between two times | Excel Worksheet Functions | |||
Calculate the difference between two times | Excel Worksheet Functions | |||
Calculate the difference between two times | Excel Worksheet Functions |