LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
Kevin B
 
Posts: n/a
Default Delete a row if blank cell

The following macro will work if the data is in Sheet1 and column A has
values in the first row through the last. If Column A is blank it exits the
loop and stops the macro, otherwise it checks the values in columns I and H
and if both are blank it deletes the row.
I've tested this some and it worked okay.

Sub RemoveRows()

Dim wb As Workbook
Dim ws As Worksheet
Dim lngRow As Long
Dim lngRowOffset As Long
Dim intColOffset As Integer
Dim lngCurrentRow As Long
Dim varVal1 As Variant
Dim varVal2 As Variant
Dim varVal3 As Variant
Set wb = ActiveWorkbook
Set ws = wb.Worksheets("Sheet1")

ws.Activate
Range("A1").Select
varVal3 = ActiveCell.Offset(lngRowOffset).Value
Application.ScreenUpdating = False

Do Until varVal3 = ""
varVal1 = ActiveCell.Offset(lngRowOffset, 7).Value
varVal2 = ActiveCell.Offset(lngRowOffset, 8).Value
lngCurrentRow = lngRowOffset + 1
If varVal1 = "" And varVal2 = "" Then
ws.Rows(lngCurrentRow & ":" & lngCurrentRow).Delete
End If
lngRowOffset = lngRowOffset + 1
varVal3 = ActiveCell.Offset(lngRowOffset).Value
Loop

Set wb = Nothing
Set ws = Nothing
Application.ScreenUpdating = True

End Sub
--
Kevin Backmann


"mohd21uk via OfficeKB.com" wrote:

I would like to delete a row if the the value in colmn I and H in the
respective row is blank. I would like to know if a macro can do this from the
start to the end of the worksheet.

Thanks.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...excel/200605/1

 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum in first blank cell and a few more things... Bleu_808 Excel Discussion (Misc queries) 3 May 4th 06 12:00 PM
Instead of a negative number, I'd like to show zero... Dr. Darrell Excel Worksheet Functions 6 December 7th 05 08:21 PM
How to delete blank rows John Mansfield Excel Discussion (Misc queries) 3 April 27th 05 11:48 PM
blank cell turns to 0 LMB New Users to Excel 2 April 25th 05 03:57 PM
VLookup resulting in a blank cell... KempensBoerke Excel Worksheet Functions 1 October 28th 04 09:57 PM


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

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

About Us

"It's about Microsoft Excel"