A very particular way to select data

gregmartjim

New Member
Joined
Jun 14, 2018
Messages
9
Hello Mr Excel and everyone

I have a problem , i am trying to select some data from a set but in a very particular way.
the data i have is something like the data below, what id like to do is to delete the whole row if the number in the second column is repeated, but i want to keep the last repeated value and delete the other values above.

For example the first and second row have the same value in column 2 (the value is 1) i want to delete all the first row and just leave the second one. An other example, the rows 9 to 11 have the same value in column 2 (the value is 1 again) here i would like to delete row 9 & 10. Final example, the rows 3 and 4 have the same value (2) i would like to delete all row number 3 and keep row 4. I will really appreciate if someone could help me with this problem. Thanks for reading

110.6441.931274.895
110.6641.121274.8375
120.9740.681290.7075
120.9341.881290.7075
131.1144.381311.235
130.8341.921311.12
141.1842.831331.245
141.5843.261331.4175
110.5754.071270.98
110.5755.141270.98
110.6856.191270.98
120.5253.81290.96
120.5653.361290.78
130.7658.581310.94
130.6456.71310.76
140.7549.141331.1
140.846.671331.1
110.4852.051271.34
110.5251.571271.34
110.5250.411271.34
120.750.841291.14
120.651.761291.14
130.6954.791311.12
130.855.451311.12
140.8351.361331.1
141.0552.731331.1
110.4739.461271.0425
110.4139.521270.985
120.5853.11290.995
120.652.651290.995
131.0552.441311.12
130.9853.371311.12
141.0748.861331.015
141.147.461331.015
110.4256.861270.98
110.4454.531270.98
120.4250.121290.96
120.4351.051290.96
130.5858.821310.76
130.5457.631310.76
140.7948.761331.1
140.7948.211331.1

<colgroup><col span="4"><col></colgroup><tbody>
</tbody>
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You can do this without a macro if you want, but if this is a recurring task I recommend the VBA route.

But manually for starters, assuming your data as you presented it starts in row 1, then in cell F2 enter and copy down
=IF(OR(B2=B1,B2<>B3),"X","")

Then filter column F for X

Then, select from the second visible row to the end of the filtered range, hit F5 > Special > Visible cells only > OK

Then from your Ribbon, select the Home tab > Delete > Delete sheet rows.

Finally, exit Filter mode and delete or clear column F.
 
Upvote 0
Hello Tom
Thanks for the answer, i am kind of lost, what should i put instead of the "X", also i need to do the same for all the values in column B, some times i got 2 some others i got more.

Regards
 
Upvote 0
The formula should be taken literally. You put the X in it just as I wrote.

This does evaluate column B and it does what you said in your first post: it deleted the rows you said you want to be deleted. On a copy of your workbook, try following the steps just as I wrote them, it should do what you said you want.
 
Upvote 0
well i tried as you told me but i just get an X in the column, this is a shorten version of the real data, i change the formula you gave me for this

one =IF(OR(D2=D3,D2<>D3),"X","") , and i put it in column H, notice that in H2 i just got an X.


NNK6-0272110.6441.931274.895X
NNK6-0272110.6641.121274.8375
NNK6-0272120.9740.681290.7075
NNK6-0272120.9341.881290.7075
NNK6-0272131.1144.381311.235
NNK6-0272130.8341.921311.12
NNK6-0272141.1842.831331.245
NNK6-0272141.5843.261331.4175
TA01-0013110.5754.071270.98
TA01-0013110.5755.141270.98
TA01-0013110.6856.191270.98
TA01-0013120.5253.81290.96
TA01-0013120.5653.361290.78
TA01-0013130.7658.581310.94
TA01-0013130.6456.71310.76
TA01-0013140.7549.141331.1
TA01-0013140.846.671331.1
TA01-0024110.4852.051271.34
TA01-0024110.5251.571271.34
TA01-0024110.5250.411271.34
TA01-0024120.750.841291.14
TA01-0024120.651.761291.14
TA01-0024130.6954.791311.12
TA01-0024130.855.451311.12
TA01-0024140.8351.361331.1
TA01-0024141.0552.731331.1

<colgroup><col span="6"><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
@gregmartjim
Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it.
Please be patient and do not attempt to post the question again.
 
Upvote 0
You changed the data range from your first post to involve more columns which is no big deal except that you did not adjust the formula accordingly.

You changed the formula to this:
Code:
=IF(OR(D2=D3,D2<>D3),"X","")
but it should have been changed to this:
Code:
=IF(OR(D2=[COLOR=#b22222][B]D1[/B][/COLOR],D2<>D3),"X","")

When you do that and follow the rest of the steps from my first post on this thread, you should get the result you said you want because it works for me.
 
Upvote 0
Thanks again Tom

It works nice when i have to select between 2 but not when i have 3 of the same, when this happens i get the x in the last two. herean example, from D3 to D5 i have the same number, and i would like to select just all the row from D5, right now i get D4 and D5. The column D i some times have two rows with the same number, some times 3, some times 4 or even more and i just want to select the last one.

Regards

TA01-01012110.3840.751270.9275-
TA01-01012110.5439.161270.985x
TA01-01012120.5852.81291.0525-
TA01-01012120.6150.391291.0525x
TA01-01012120.6750.91291.11x
TA01-01012130.8654.91310.89-
TA01-01012131.0955.091310.9475x
TA01-01012140.9946.51330.6125-
TA01-01012140.9945.441330.6125x
TA01-01012141.1846.831330.6125x

<colgroup><col span="6"><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
If in cell H1 (notice, that's H1 this time, not H2) you enter this formula and copy it down, does it place the X's where it should, meaning for those rows where an X would be in column H are the same rows you want to delete, and where there are not X's are for rows you want to keep (I assume your word "select" is the same as keep).

Code:
=IF(OR(D1=D2,D2<>D3),"X","")
 
Upvote 0

Forum statistics

Threads
1,215,148
Messages
6,123,301
Members
449,095
Latest member
Chestertim

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top