Hi all,
I am struggling with this for a while... I have the following excel sheet as an example data set
Column A Column B Column C Column D
1 First names Last names Fruits Basket sizes
2 John Smith Raspberry 03 - Basket
3 John Smith Raspberry 05 - Basket
4 John Smith Raspberry 03 - Basket
5 John Smith Cherry Small Basket
6 John Smith Raspberry 03 - Basket
7 Jane Doe Raspberry 03 - Basket
8 Jane Doe Raspberry Small Basket
9 John Page Apple 03 - Basket
10 John Page Apple 03 - Basket
11 John Page Apple Small Basket
12 John Page Apple 05 - Basket
13 Grace Smith Raspberry 03 - Basket
14 Grace Smith Apple 05 - Basket
15 Grace Smith Cherry Small Basket
This is a table, so a listobject, and first row is header row (pretty obviously)
What I would like to do is write a VBA code to get rid of lines that are the same first and last name, and the same fruit, and only keep 1 line (remove duplicates/triplicates)
Either ignoring what is in Column D, or possibly, if there is an 05-Basket, that should be the line that is kept, if there is no "05*" it doesn't matter which line is kept. Also if it can't be done this way and lets say its always the first or last row of the group that is kept that is also good I will just sort it first. (Additional info, there will never be more than one 05 - Basket for the same name and fruit)
So the optimal outcome of this would be:
Column A Column B Column C Column D
1 First names Last names Fruits Basket sizes
2 John Smith Raspberry 05 - Basket
3 John Smith Cherry Small Basket
4 Jane Doe Raspberry 03 - Basket
5 John Page Apple 05 - Basket
6 Grace Smith Raspberry 03 - Basket
7 Grace Smith Apple 05 - Basket
8 Grace Smith Cherry Small Basket
I'm open to any creative solutions.. maybe a column could be inserted as "sorting column" in which the first names, last names and fruits are combined? And based on that column delete duplicates/triplicates?
If empty rows are left, that's also fine I will get rid of them after.
I really just need to figure out how to get rid of the unnecessary rows.. its weeks that I am trying to do this but I am quite new to VBA so its a bit above me yet.. hence if you have a solution, could you also give an explanation on how it does what it does please? I would like to learn.
Please help!
Thank you!
I am struggling with this for a while... I have the following excel sheet as an example data set
Column A Column B Column C Column D
1 First names Last names Fruits Basket sizes
2 John Smith Raspberry 03 - Basket
3 John Smith Raspberry 05 - Basket
4 John Smith Raspberry 03 - Basket
5 John Smith Cherry Small Basket
6 John Smith Raspberry 03 - Basket
7 Jane Doe Raspberry 03 - Basket
8 Jane Doe Raspberry Small Basket
9 John Page Apple 03 - Basket
10 John Page Apple 03 - Basket
11 John Page Apple Small Basket
12 John Page Apple 05 - Basket
13 Grace Smith Raspberry 03 - Basket
14 Grace Smith Apple 05 - Basket
15 Grace Smith Cherry Small Basket
This is a table, so a listobject, and first row is header row (pretty obviously)
What I would like to do is write a VBA code to get rid of lines that are the same first and last name, and the same fruit, and only keep 1 line (remove duplicates/triplicates)
Either ignoring what is in Column D, or possibly, if there is an 05-Basket, that should be the line that is kept, if there is no "05*" it doesn't matter which line is kept. Also if it can't be done this way and lets say its always the first or last row of the group that is kept that is also good I will just sort it first. (Additional info, there will never be more than one 05 - Basket for the same name and fruit)
So the optimal outcome of this would be:
Column A Column B Column C Column D
1 First names Last names Fruits Basket sizes
2 John Smith Raspberry 05 - Basket
3 John Smith Cherry Small Basket
4 Jane Doe Raspberry 03 - Basket
5 John Page Apple 05 - Basket
6 Grace Smith Raspberry 03 - Basket
7 Grace Smith Apple 05 - Basket
8 Grace Smith Cherry Small Basket
I'm open to any creative solutions.. maybe a column could be inserted as "sorting column" in which the first names, last names and fruits are combined? And based on that column delete duplicates/triplicates?
If empty rows are left, that's also fine I will get rid of them after.
I really just need to figure out how to get rid of the unnecessary rows.. its weeks that I am trying to do this but I am quite new to VBA so its a bit above me yet.. hence if you have a solution, could you also give an explanation on how it does what it does please? I would like to learn.
Please help!
Thank you!