Hi folks!
I'm having troubles figuring out a way to move data from multiple columns (that are not text to each other) based on a different column that is being compared to yet another column:
The file that I'm using has over 12k rows and what I'm aiming to do is get the data from columns A and C to another worksheet. The main issue is that I need to copy said values for each unique identifier separately (so for example first I need to copy the values for all Identifiers (column B) with value "ID1" and so on).
I've gathered all the unique Identifiers to another column by using
and this part works fine (around 1200 unique values)
So now the next step would be to use the column with unique identifiers and for each of these search for rows with the same identifier and get the A and C values from those copied to yet another worksheet.
My general idea on how this would work was something in the shape of For Each value in column X (Unique Identifiers) with If nested
Now there are two issues with the above:
1. It's not a proper code
2. Wouldn't this kind of loop take a long time to finish? Since it's going to scan all the Identifiers (12k) every single time.
I'd be grateful for any help with the code part of this issue and with any corrections to my approach!
I'm having troubles figuring out a way to move data from multiple columns (that are not text to each other) based on a different column that is being compared to yet another column:
The file that I'm using has over 12k rows and what I'm aiming to do is get the data from columns A and C to another worksheet. The main issue is that I need to copy said values for each unique identifier separately (so for example first I need to copy the values for all Identifiers (column B) with value "ID1" and so on).
I've gathered all the unique Identifiers to another column by using
VBA Code:
Range("B2:B12000").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("X2"), Unique:=True
So now the next step would be to use the column with unique identifiers and for each of these search for rows with the same identifier and get the A and C values from those copied to yet another worksheet.
A | B | C | Unique Identifiers |
aaa | ID1 | eee | ID1 |
sss | ID5 | fff | ID5 |
zzz | ID2 | ggg | ID2 |
ddd | ID1 | hhh |
My general idea on how this would work was something in the shape of For Each value in column X (Unique Identifiers) with If nested
Code:
For Each c In Range("X:X")
If c = value in column B
Copy values A and D using B row number
Paste them to another worksheet
Then look further if there are any matching values in column B
If yes - copy the values again and paste them to another worksheet (below the ones that were previously pasted)
Else
End If
Now there are two issues with the above:
1. It's not a proper code
2. Wouldn't this kind of loop take a long time to finish? Since it's going to scan all the Identifiers (12k) every single time.
I'd be grateful for any help with the code part of this issue and with any corrections to my approach!