VBA delete all row after row

Jeeremy7

Board Regular
Joined
May 13, 2020
Messages
101
Office Version
  1. 365
Platform
  1. Windows
Hello,

I was wondering what was the code for deleting all row values after the macro sees a certain text in column A ?

Thanks !
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,436
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Sub jeeremy()
   Dim Fnd As Range
   
   Set Fnd = Range("A:A").Find("something", , , xlWhole, , , False, , False)
   If Fnd Is Nothing Then Exit Sub
   Range(Fnd.Offset(1), Cells(Rows.Count, 1)).EntireRow.Delete
End Sub
 

Jeeremy7

Board Regular
Joined
May 13, 2020
Messages
101
Office Version
  1. 365
Platform
  1. Windows
THANKS !

Fluff for the win like always hehe
Can I delete the "something" row on the same code ?

Also what are those DIM "" AS "" is that like a rule ?

Thanks again Fluff .. I might post something else again today :p
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,436
Office Version
  1. 365
Platform
  1. Windows
To delete the found row use
VBA Code:
Range(Fnd, Cells(Rows.Count, 1)).EntireRow.Delete
DIM statements are a way of declaring variables.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,436
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 
Solution
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,626
Messages
5,838,429
Members
430,547
Latest member
jopshio

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
Top