montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 984
- Office Version
- 2010
- Platform
- Windows
hello, I am trying to subtract columns and I write this code but results are complet wrong, is a dynamic array start A1:F250 , I am looking to subtract col B-A results on H, C-B results on I, D-C results on J etc. this is what I tryed.
is just integers. thanks
Code:
Sub test()
'subtract b-a, c-b, d-c, e-d
'the results on H, I, J, K
Dim x As Integer
Dim y As Integer
For x = 1 To 5
For y = 1 To 4
Cells(x, "h").Value = Cells(x, "h").Value - Cells(x, y).Value
Cells(x, "I").Value = Cells(x, "i").Value - Cells(x, y).Value
Cells(x, "j").Value = Cells(x, "j").Value - Cells(x, y).Value
Cells(x, "k").Value = Cells(x, "h").Value - Cells(x, y).Value
Next y
Next x
End Sub