#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA

Could some pls help me with the below macro.

Starting from row 5 to say 200

I want to delete the entire row if a cell in Col B is blank/empty.

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA

When deleting rows, you should always work from the bottom up.

Dim RowNdx As Long
For RowNdx = 200 To 5 Step -1
If Cells(RowNdx, "B").Value = "" Then
Rows(RowNdx).Delete
End If
Next RowNdx



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
oups.com...
Could some pls help me with the below macro.

Starting from row 5 to say 200

I want to delete the entire row if a cell in Col B is
blank/empty.

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA

option explicit
sub testme01()

dim iRow as long
dim delRng as range

with activesheet
for irow = 5 to 200
if .cells(irow,"B").value = "" then
if delrng is nothing then
set delrng = .cells(Irow,"A")
else
set delrng = union(delrng,.cells(irow,"A"))
end if
end if
next irow
end with

if delrng is nothing then
'do nothing
else
delrng.entirerow.delete
end if

end sub

" wrote:

Could some pls help me with the below macro.

Starting from row 5 to say 200

I want to delete the entire row if a cell in Col B is blank/empty.

Thanks


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default VBA

Range("B5:B200").SpecialCells(xlCellTypeBlanks).En tireRow.Delete



" wrote:

Could some pls help me with the below macro.

Starting from row 5 to say 200

I want to delete the entire row if a cell in Col B is blank/empty.

Thanks


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"