VBA delete all row after row

Jeeremy7

Board Regular
Joined
May 13, 2020
Messages
63
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 !
 

Some videos you may like

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,412
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
63
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
55,412
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
55,412
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,316
Messages
5,623,968
Members
416,002
Latest member
Neshx

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