Cyber_Cyrus
New Member
- Joined
- Jun 11, 2021
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Good Day All,
The motivation behind the post is to find out if there is perhaps a more efficient way I can query Excel to find multiple results for a single reference.
Please refer to the below example:
As you can see from the above screenshot, I am working with 4 columns. The first (M), is the reference of a particular Sales Order. The left function was used to show only the Sales Order reference and not the transaction attempt (SO12345X1, SO12345X2, etc) The Second (N), is the number of times this reference comes forth in the list. Third (O), is the total transaction attempt for that specific reference, and the fourth(P), is my attempt to solve my own question.
If we use the highlighted record as reference (SO722299), we can see that it appears a total of 3 times within the list. Additionally, the other two times it appears, it has values of 1 transaction each. Through this I can calculate that a total of 9 transactions were made for that specific order.
I applied VBA to calculate the values within column P.
Function CusVlookup(lookupval, lookuprange As Range, indexcol As Long)
'updateby Extendoffice
Dim x As Range
Dim result As String
result = ""
For Each x In lookuprange
If x = lookupval Then
result = result & " " & x.Offset(0, indexcol - 1)
End If
Next x
CusVlookup = result
End Function
The only problem is that I work with thousands of records and I would assume it would take hours before it returns a result for each record. So that brings me back to my question. Is there a more efficient way to get the data I need (Total transaction per Order)?
The motivation behind the post is to find out if there is perhaps a more efficient way I can query Excel to find multiple results for a single reference.
Please refer to the below example:
As you can see from the above screenshot, I am working with 4 columns. The first (M), is the reference of a particular Sales Order. The left function was used to show only the Sales Order reference and not the transaction attempt (SO12345X1, SO12345X2, etc) The Second (N), is the number of times this reference comes forth in the list. Third (O), is the total transaction attempt for that specific reference, and the fourth(P), is my attempt to solve my own question.
If we use the highlighted record as reference (SO722299), we can see that it appears a total of 3 times within the list. Additionally, the other two times it appears, it has values of 1 transaction each. Through this I can calculate that a total of 9 transactions were made for that specific order.
I applied VBA to calculate the values within column P.
Function CusVlookup(lookupval, lookuprange As Range, indexcol As Long)
'updateby Extendoffice
Dim x As Range
Dim result As String
result = ""
For Each x In lookuprange
If x = lookupval Then
result = result & " " & x.Offset(0, indexcol - 1)
End If
Next x
CusVlookup = result
End Function
The only problem is that I work with thousands of records and I would assume it would take hours before it returns a result for each record. So that brings me back to my question. Is there a more efficient way to get the data I need (Total transaction per Order)?