Hello,
I have this code involving adding 3 bits of data to 3 multi dimensional arrays - running some processes and then printing back from one array
Problem I am having is writing the calculated result back to the array
Please have a look and tell me where I am wrong.. I am not posting the entirety of the code to keep things simple and understandable
Here is the watch window result stopped just after I expect the findings to be printed
not sure where I'm going wrong... so I'll gladly provide a snippet of the data I'm working with
Basically at this point ... column two should be broken down and the two sets of numbers should be added to the array - after which I will be running further calculations on them.. but I'm having trouble getting that bit down
I have this code involving adding 3 bits of data to 3 multi dimensional arrays - running some processes and then printing back from one array
Problem I am having is writing the calculated result back to the array
Please have a look and tell me where I am wrong.. I am not posting the entirety of the code to keep things simple and understandable
VBA Code:
Sub indexARray_V2()
TurnOff
On Error Resume Next
Dim Sponsor As Double
Dim a() As Variant 'this is the first array - code looks in here for results
Dim b() As Variant 'this is the second array - code looks in here for results if not found in first array
Dim data() As Variant 'this is where I get the search data -- first and second array results are also printed here in different columns
lastrow_chart = chart1.Cells(1, 1).End(xlDown).Row
lastrow_chart2 = chart2.Cells(Rows.Count, 1).End(xlUp).Row
lastrow = ws.Cells(Rows.Count, 1).End(xlUp).Row
Dim currentMax As Long, startingPoint As Long
startingPoint = 507552
currentMax = lastrow
ReDim a(1 To lastrow_chart, 1 To 24) As Variant
a = chart1.Range("A2:X" & lastrow_chart)
ReDim b(1 To lastrow_chart2, 1 To 24) As Variant
b = chart1.Range("A2:X" & lastrow_chart2)
ReDim data(startingPoint To currentMax, 1 To 12) As Variant
data = ws.Range("A" & startingPoint & ":L" & currentMax)
For i = startingPoint To currentMax
currentRow = i - startingPoint + 1
Buyer = FirstNumber(data(currentRow, 2)) 'Private Function to get back the first string of numbers from the transaction ID (in data array)
Sponsor = Right(data(currentRow, 2), Len(data(currentRow, 2)) - narrationType) 'Get the last bit of numbers from the string (in data array)
data(currentRow, 8) = Sponsor 'At this point I expect the code to write to the same row in the data array to the 8th column; but unfortunately this does not happen - watch window results are Empty
If Len(Buyer) = 7 Or Len(Buyer) = 11 Then data(currentRow, 7).Value = Buyer 'Buyer value should be printed to the array too .. but it does not.
Here is the watch window result stopped just after I expect the findings to be printed
not sure where I'm going wrong... so I'll gladly provide a snippet of the data I'm working with
Book1 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | |||
1 | Date(Unformatted) | Transaction ID | Narration | Date2(Unformatted) | Withdrawal | Deposit Amount | Buyer | Sponsor | Date | 1st Pay/PayOff | Unique | Remarks | ||
2 | 03/01/22 | T36000007401I3535079 | N003221776811807 | 03/01/22 | 24225 | 2022/01/03 | OK | |||||||
3 | 03/01/22 | T36000007401I3530776 | N003221776811804 | 03/01/22 | 4037.5 | 2022/01/03 | OK | |||||||
4 | 03/01/22 | T000050497I000046696 | N003221776811811 | 03/01/22 | 2850 | 2022/01/03 | OK | |||||||
Sheet1 |
Basically at this point ... column two should be broken down and the two sets of numbers should be added to the array - after which I will be running further calculations on them.. but I'm having trouble getting that bit down