Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 164
Default If, Then, Delete Entire Row, Loop, End

Hi,

I appreciate your help.
I need to run a conditional If Then statement on a defined table. If the
cell in column 1 is blank or null, then delete the entire row, and run this
statement on every row until the end of the table.

Thanks again!,
JC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default If, Then, Delete Entire Row, Loop, End

Hi JC

Try this, just change TargetRange as desired.

Sub DeleteEmptyRow()
Dim TargetRange As Range
Set TargetRange = Range("A10:A20") '<==Change to suit

EndRow = TargetRange.Cells(1, 1).Row
StartRow = TargetRange.Rows.Count + EndRow - 1

For r = StartRow To EndRow Step -1
If Cells(r, 1).Value = "" Or Cells(r, 1).Value = 0 Then
Rows(r).Delete
End If
Next
End Sub

Regards,
Per

"JC" skrev i meddelelsen
...
Hi,

I appreciate your help.
I need to run a conditional If Then statement on a defined table. If the
cell in column 1 is blank or null, then delete the entire row, and run
this
statement on every row until the end of the table.

Thanks again!,
JC


  #3   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 164
Default If, Then, Delete Entire Row, Loop, End

Thanks Per,

I actually decided to select the range of the first column, then use the Go
To, Special, Blanks and then Delete entire rows.

I appreciate your help. Here is my code. I comment out a lot, but I am a
novice at this. Thx!

Sub Delete_Blank_Rows()
'
' Delete Blank Object Code Rows, Selects Expenditures sheet
'
Sheets("Expenditures").Select
'
' Delete Blank Object Code Rows on Budget Entries
'
Range("TblBudgetExp[[#All],[Obj]]").Select
Range("B268").Activate
Selection.SpecialCells(xlCellTypeBlanks).EntireRow .Delete
'
' Delete Blank Rows on Transfers
'
Range("TblTransfersExp[[#All],[Obj]]").Select
Range("B259").Activate
Selection.SpecialCells(xlCellTypeBlanks).EntireRow .Delete
'
' Delete Blank Rows on Actuals
'
Range("TblActualsExp[[#All],[Obj ]]").Select
Range("B224").Activate
Selection.SpecialCells(xlCellTypeBlanks).EntireRow .Delete

'
' Selects Revenue Sheet
'

Sheets("Revenue").Select
'
' Delete Blank Rows on Revenue Budget Entries
'

Range("TblBudgetRev[[#All],[Obj]]").Select
Range("B21").Activate
Selection.SpecialCells(xlCellTypeBlanks).EntireRow .Delete

End Sub

I hope I don't comment out on this, but I'm a novice and I try to sleep
between these sessions.

Thx!
JC












JC

"Per Jessen" wrote:

Hi JC

Try this, just change TargetRange as desired.

Sub DeleteEmptyRow()
Dim TargetRange As Range
Set TargetRange = Range("A10:A20") '<==Change to suit

EndRow = TargetRange.Cells(1, 1).Row
StartRow = TargetRange.Rows.Count + EndRow - 1

For r = StartRow To EndRow Step -1
If Cells(r, 1).Value = "" Or Cells(r, 1).Value = 0 Then
Rows(r).Delete
End If
Next
End Sub

Regards,
Per

"JC" skrev i meddelelsen
...
Hi,

I appreciate your help.
I need to run a conditional If Then statement on a defined table. If the
cell in column 1 is blank or null, then delete the entire row, and run
this
statement on every row until the end of the table.

Thanks again!,
JC



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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving an entire range and a for loop question Dreaded404 Excel Programming 2 July 2nd 08 03:15 PM
Delete entire row if David T Excel Discussion (Misc queries) 2 December 6th 06 10:14 PM
Need to delete last value in column but not delete entire row [email protected] Excel Programming 4 October 19th 06 05:26 PM
Delete Entire Row If Q John Excel Programming 10 June 9th 04 03:02 PM
Delete Entire Row. Sam Excel Programming 5 December 21st 03 05:56 AM


All times are GMT +1. The time now is 02:18 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"