Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
AndyG
 
Posts: n/a
Default Delete row based on contents of cell

The following code does a great job of finding whole blank rows and deleting
them:

Range("B1", Range("B65536").End(xlUp)).SpecialCells _
(xlCellTypeBlanks).EntireRow.Delete

However, could someone please tell me how to modify this for two other
purposes:

1) Delete the whole row if any cell in column A: is has the contents of "SSN"

2) Delete the whole row if any cell in column C: is blank (null?)

Thank you in advance.
  #3   Report Post  
Posted to microsoft.public.excel.misc
AndyG
 
Posts: n/a
Default Delete row based on contents of cell

Thank you Don,
I do know how to use the datafilterautofilter then custom, not equal to
"SSN" to filter out the row in the view, however I really would like to
programmatically (macro) delete the row. If I have filters on I am also
limited (can't insert columns, etc.). Should I have posted this to the
Programming/Coding section instead of here?

Thank you again

"Don Guillett" wrote:

One way is to use datafilterautofilter and record while doing it to
learn. Post back after you have tried this with addl questions.

--
Don Guillett
SalesAid Software

"AndyG" wrote in message
...
The following code does a great job of finding whole blank rows and
deleting
them:

Range("B1", Range("B65536").End(xlUp)).SpecialCells _
(xlCellTypeBlanks).EntireRow.Delete

However, could someone please tell me how to modify this for two other
purposes:

1) Delete the whole row if any cell in column A: is has the contents of
"SSN"

2) Delete the whole row if any cell in column C: is blank (null?)

Thank you in advance.




  #4   Report Post  
Posted to microsoft.public.excel.misc
Ron de Bruin
 
Posts: n/a
Default Delete row based on contents of cell

See
http://www.rondebruin.nl/delete.htm

This Add-in have this option also
http://www.rondebruin.nl/easyfilter.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"AndyG" wrote in message ...
Thank you Don,
I do know how to use the datafilterautofilter then custom, not equal to
"SSN" to filter out the row in the view, however I really would like to
programmatically (macro) delete the row. If I have filters on I am also
limited (can't insert columns, etc.). Should I have posted this to the
Programming/Coding section instead of here?

Thank you again

"Don Guillett" wrote:

One way is to use datafilterautofilter and record while doing it to
learn. Post back after you have tried this with addl questions.

--
Don Guillett
SalesAid Software

"AndyG" wrote in message
...
The following code does a great job of finding whole blank rows and
deleting
them:

Range("B1", Range("B65536").End(xlUp)).SpecialCells _
(xlCellTypeBlanks).EntireRow.Delete

However, could someone please tell me how to modify this for two other
purposes:

1) Delete the whole row if any cell in column A: is has the contents of
"SSN"

2) Delete the whole row if any cell in column C: is blank (null?)

Thank you in advance.






  #5   Report Post  
Posted to microsoft.public.excel.misc
AndyG
 
Posts: n/a
Default Delete row based on contents of cell

Thank you very much Ron. The link you supplied showed me the code I needed.
God bless you for being willing to share your expertise. Thank you, Andy

"Ron de Bruin" wrote:

See
http://www.rondebruin.nl/delete.htm

This Add-in have this option also
http://www.rondebruin.nl/easyfilter.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"AndyG" wrote in message ...
Thank you Don,
I do know how to use the datafilterautofilter then custom, not equal to
"SSN" to filter out the row in the view, however I really would like to
programmatically (macro) delete the row. If I have filters on I am also
limited (can't insert columns, etc.). Should I have posted this to the
Programming/Coding section instead of here?

Thank you again

"Don Guillett" wrote:

One way is to use datafilterautofilter and record while doing it to
learn. Post back after you have tried this with addl questions.

--
Don Guillett
SalesAid Software

"AndyG" wrote in message
...
The following code does a great job of finding whole blank rows and
deleting
them:

Range("B1", Range("B65536").End(xlUp)).SpecialCells _
(xlCellTypeBlanks).EntireRow.Delete

However, could someone please tell me how to modify this for two other
purposes:

1) Delete the whole row if any cell in column A: is has the contents of
"SSN"

2) Delete the whole row if any cell in column C: is blank (null?)

Thank you in advance.








  #6   Report Post  
Posted to microsoft.public.excel.misc
Olivia Trimble
 
Posts: n/a
Default Delete row based on contents of cell

Can this be used to delete cells only if the have returned blank as a False
response to a function?

"AndyG" wrote:

The following code does a great job of finding whole blank rows and deleting
them:

Range("B1", Range("B65536").End(xlUp)).SpecialCells _
(xlCellTypeBlanks).EntireRow.Delete

However, could someone please tell me how to modify this for two other
purposes:

1) Delete the whole row if any cell in column A: is has the contents of "SSN"

2) Delete the whole row if any cell in column C: is blank (null?)

Thank you in advance.

  #7   Report Post  
Posted to microsoft.public.excel.misc
Ron de Bruin
 
Posts: n/a
Default Delete row based on contents of cell

Hi Olivia

No, you must test for "" then in a loop
Example that test A1:A100

Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 100
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf .Cells(Lrow, "A").Value = "" Then .Rows(Lrow).Delete

End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Olivia Trimble" wrote in message
...
Can this be used to delete cells only if the have returned blank as a False
response to a function?

"AndyG" wrote:

The following code does a great job of finding whole blank rows and deleting
them:

Range("B1", Range("B65536").End(xlUp)).SpecialCells _
(xlCellTypeBlanks).EntireRow.Delete

However, could someone please tell me how to modify this for two other
purposes:

1) Delete the whole row if any cell in column A: is has the contents of "SSN"

2) Delete the whole row if any cell in column C: is blank (null?)

Thank you in advance.



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 do I conditionally delete rows based on cell contents? John Chan Excel Worksheet Functions 3 May 17th 23 03:45 AM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
Sum numbers based on the contents of another cell Doreen Excel Worksheet Functions 5 May 5th 05 04:41 PM
Lookup cell contents in on sheet based on a formula in second sheet Michael Wright via OfficeKB.com Excel Worksheet Functions 1 April 30th 05 04:11 PM
Returning a Value to a Cell Based on a Range of Uncertain Size amc422 Excel Worksheet Functions 7 November 14th 04 03:03 PM


All times are GMT +1. The time now is 08:23 AM.

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"