ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   visual basic macro code for deleting referenced rows (https://www.excelbanter.com/excel-programming/289486-re-visual-basic-macro-code-deleting-referenced-rows.html)

mudraker[_132_]

visual basic macro code for deleting referenced rows
 
Try this - checks a1 to a12 deleting rows if the cell is blank.



to find the last row used in a column replace
For r = 12 To 1 Step -1
with
For r = Range("a65536").End(xlUp).Row To 1 Step -1




Sub DelRow()
Dim r As Long
For r = 12 To 1 Step -1
If Cells(r, "a") = "" Then
Rows(r).Delete
End If
Next r
End Su

--
Message posted from http://www.ExcelForum.com


nathan

visual basic macro code for deleting referenced rows
 
Thanks for the advice, but my question wasn't clear. I have a single column with cells that either contain text or a value. I need to select those cells that contain a value and delete the rows those cells are in. I want to keep the rows that cells with text are in. Thanks again.

Tom Ogilvy

visual basic macro code for deleting referenced rows
 
Columns(1).SpecialCells(xlConstants,xlNumbers).Ent ireRow.Delete

--
Regards,
Tom Ogilvy

nathan wrote in message
...
Thanks for the advice, but my question wasn't clear. I have a single

column with cells that either contain text or a value. I need to select
those cells that contain a value and delete the rows those cells are in. I
want to keep the rows that cells with text are in. Thanks again.



nathan

visual basic macro code for deleting referenced rows
 
So hard and yet so easy! Thanks, it works great.


All times are GMT +1. The time now is 05:45 PM.

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