ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Delete rows using a macro (https://www.excelbanter.com/excel-discussion-misc-queries/232709-delete-rows-using-macro.html)

Sasikiran

Delete rows using a macro
 
Hello,

I need help with a macro that will delete certain rows in a spreadsheet.
The rows that need to be deleted are never in the same place, or the same
number of rows. The thing that the rows I want to delete all have in common
a specific word say "YES" in the same column. But they are never in the same
place everytime.

Please suggest me on this.

Gary''s Student

Delete rows using a macro
 
Here is a typical example. The macro deletes any rows with "YES" in column B:

Sub YESMan()
n = Cells(Rows.Count, "B").End(xlUp).Row
For i = n To 1 Step -1
If Cells(i, "B").Value = "YES" Then
Cells(i, "B").EntireRow.Delete
End If
Next
End Sub

--
Gary''s Student - gsnu200855


"Sasikiran" wrote:

Hello,

I need help with a macro that will delete certain rows in a spreadsheet.
The rows that need to be deleted are never in the same place, or the same
number of rows. The thing that the rows I want to delete all have in common
a specific word say "YES" in the same column. But they are never in the same
place everytime.

Please suggest me on this.


Sasikiran

Delete rows using a macro
 
Thanks a ton :)

"Gary''s Student" wrote:

Here is a typical example. The macro deletes any rows with "YES" in column B:

Sub YESMan()
n = Cells(Rows.Count, "B").End(xlUp).Row
For i = n To 1 Step -1
If Cells(i, "B").Value = "YES" Then
Cells(i, "B").EntireRow.Delete
End If
Next
End Sub

--
Gary''s Student - gsnu200855


"Sasikiran" wrote:

Hello,

I need help with a macro that will delete certain rows in a spreadsheet.
The rows that need to be deleted are never in the same place, or the same
number of rows. The thing that the rows I want to delete all have in common
a specific word say "YES" in the same column. But they are never in the same
place everytime.

Please suggest me on this.



All times are GMT +1. The time now is 03:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com