VBA code for deleting rows between specific values

siyagupta

New Member
Joined
Jun 29, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
i need a vba code to delete all the rows between two cells, excluding those cells and loop it as many times as those cells appear. i tried chatgpt but couldn't find a working code
I cant upload the file but it is something like
xyz
ABC
mba


mcd
acd

xyz ABC mba

mcd
acd
.
.
.

here I need to delete all the rows between mba and mcd, while keeping both mba and mcd. PLEASE HELP
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi, It would be good if you can provide more sample data through mini sheet via XLBB with expected result for better understanding

Want to help your helpers by posting a small, copyable, screen shot directly in your post? XL2BB Instructions & Download (latest January 2021 v 2.0 )


You could upload a copy of your file to a free site such www.dropbox.com or google drive. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.

Book1
AB
1Result:
2XYZ
3ABC
4MBA
5MCD
6ACD
7XYZ abc mba
8mcd
9asd
Sheet1


What's the full result? like column b?
Book1
AB
1Result:
2XYZXYZ
3ABCABC
4MBAACD
5MCDXYZ abc mba
6ACDmcd
7XYZ abc mbaasd
8mcd
9asd
Sheet1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,193
Messages
6,123,566
Members
449,108
Latest member
rache47

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