montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 984
- Office Version
- 2010
- Platform
- Windows
Hello, I have been trying to work around this code and do not work, any help please.
I have a row of 6 numbers at E2:J2 and one dynamic array at L2:Q I am trying to subtracting each number from E2:J2 from the array and the results at S2:X, just to simplify let think as the row (E2:J2) is 1,1,1,1,1,1 and subtracting from the array is 2,2,2,2,2,2 all the way down, the results will be of course 1,1,1,1,1,1
I try this but I don't get the right results.
I have a row of 6 numbers at E2:J2 and one dynamic array at L2:Q I am trying to subtracting each number from E2:J2 from the array and the results at S2:X, just to simplify let think as the row (E2:J2) is 1,1,1,1,1,1 and subtracting from the array is 2,2,2,2,2,2 all the way down, the results will be of course 1,1,1,1,1,1
Code:
Sub subtractone()
Dim a
Dim i As Long, j As Long, rws As Long
With Range("E2", Range("L" & Rows.Count).End(xlUp)).Resize(, 24)
a = .Value
rws = UBound(a, 1)
For i = 2 To rws
For j = 1 To 6
a(i, 14 + j) = Abs(a(1, j) - a(i, 12 + j))
Next j
Next i
.Value = a
End With
End Sub
E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |
2 | 20 | 30 | 40 | 42 | 44 | 49 | 10 | 16 | 21 | 29 | 41 | 43 | 10 | 14 | 19 | 13 | 3 | 6 | ||
3 | 12 | 17 | 30 | 43 | 44 | 46 | 8 | 13 | 10 | 1 | 0 | 3 | ||||||||
4 | 16 | 20 | 27 | 31 | 40 | 41 | 4 | 10 | 13 | 11 | 4 | 8 | ||||||||
5 | ETC. | |||||||||||||||||||
6 | ||||||||||||||||||||
7 |
Last edited by a moderator: