Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Delete Entire Row If Column C is Blank

I am trying to delete the entire row (and move all rows below up) if the
value in Column C for each row is blank. I have used the following code but
it throws up an Next Without For error, not sure where to go from here

Thanks



Sub DeleteZerosinIngredients()

With Application
.ScreenUpdating = False
.Calculation = xlManual
.MaxChange = 0.001
End With

Dim r As Range
For Each r In Selection

Sheets("Ingredient Mix").Select
With ActiveSheet
If Cells(r.Row, 3) = 0 Then r.EntireRow.Delete
Next

End With
With Application
.ScreenUpdating = True
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Delete Entire Row If Column C is Blank

John

You may try the following

Columns("C:C").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlUp

to replace
If Cells(r.Row, 3) = 0 Then r.EntireRow.Delete

HTH

noirk

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Delete Entire Row If Column C is Blank

Thanks Norika

Tried it but still get the "Next Without For error"


"norika " wrote in message
...
John

You may try the following

Columns("C:C").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.Delete Shift:=xlUp

to replace
If Cells(r.Row, 3) = 0 Then r.EntireRow.Delete

HTH

noirka


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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Delete Entire Row If Column C is Blank

John wrote:
I am trying to delete the entire row (and move all rows below up) if
the value in Column C for each row is blank. I have used the
following code but it throws up an Next Without For error, not sure
where to go from here

Thanks



Sub DeleteZerosinIngredients()

With Application
.ScreenUpdating = False
.Calculation = xlManual
.MaxChange = 0.001
End With

Dim r As Range
For Each r In Selection

Sheets("Ingredient Mix").Select
With ActiveSheet
If Cells(r.Row, 3) = 0 Then r.EntireRow.Delete
Next

End With
With Application
.ScreenUpdating = True
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

End Sub


I do it like this:

Sub deleterows()

'first select the column you want to analyse

For Each c In Selection

If Cells(c.Row, c.Column) = "" Then
c.EntireRow.Delete
Else
End If
Next c

End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Delete Entire Row If Column C is Blank

Thanks but the code below still comes up with "Next without For" compile
error

Sub DeleteZerosinSalesMix()

With Application
.ScreenUpdating = False
.Calculation = xlManual
.MaxChange = 0.001
End With


For Each c In Selection

Sheets("Sales Mix").Select
With ActiveSheet


If Cells(c.Row, c.Column) = "" Then
c.EntireRow.Delete Shift:=xlUp
Else
End If
Next c

End With
With Application
.ScreenUpdating = True
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Delete Entire Row If Column C is Blank

It worked for me without all your additional code in it.


John wrote:
Thanks but the code below still comes up with "Next without For"
compile error

Sub DeleteZerosinSalesMix()

With Application
.ScreenUpdating = False
.Calculation = xlManual
.MaxChange = 0.001
End With


For Each c In Selection

Sheets("Sales Mix").Select
With ActiveSheet


If Cells(c.Row, c.Column) = "" Then
c.EntireRow.Delete Shift:=xlUp
Else
End If
Next c

End With
With Application
.ScreenUpdating = True
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

End Sub




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
How to Delete entire rows by selecting different text in column A Doug[_5_] Excel Discussion (Misc queries) 2 November 20th 09 02:03 PM
CANNOT DELETE AN ENTIRE COLUMN ibeetb Excel Discussion (Misc queries) 4 June 23rd 06 02:55 AM
Easiest way to delete blank cells in column (not entire row) sramsey Excel Discussion (Misc queries) 4 February 16th 06 04:28 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
How to detect an entire column/row delete event? MV[_2_] Excel Programming 1 September 10th 03 01:03 PM


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