VBA. Delete row in a range if Values in Column A do not equal Cell B2

MsPretzel

New Member
Joined
Jun 14, 2018
Messages
5
I am very rusty on VBA and need some help!
I need to delete rows within a range (rows 6 to 85) if the value in Column A does not equal B2.
I have pasted some example data below

[TABLE="class: grid, width: 433"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Currency[/TD]
[TD]GBP[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Employee[/TD]
[TD]Charlie[/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Employee[/TD]
[TD]Event name[/TD]
[TD]Value[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Abi[/TD]
[TD]London[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Becky[/TD]
[TD]Singapore[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Charlie[/TD]
[TD]Paris[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Dave[/TD]
[TD]London[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]9
[/TD]
[TD]Ed[/TD]
[TD]Singapore[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Charlie[/TD]
[TD]Paris[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]Dave[/TD]
[TD]London[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]Ed[/TD]
[TD]Singapore[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]Charlie[/TD]
[TD]Paris[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]Abi[/TD]
[TD]London[/TD]
[TD]3[/TD]
[/TR]
</tbody>[/TABLE]
 
Can you please post what worked so that anyone in future can see what the solution was? Thanks mate, glad its working for you!
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Both codes should work.
I'm thinking along on the same lines as James.
In a blank cell enter =LEN(B2)
& in another blank cell enter =LEN(A7) Pointing to a cell that = B2
Do both formulae give the same results?
 
Upvote 0
They both worked, I went back and did a thorough check, I'd added an extra space in between a first and last name!
It is really appreciated, saved me from going completely crazy!
 
Upvote 0
Glad you got it sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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