Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
D Hafer - TFE
 
Posts: n/a
Default Delete all rows where Column A contains Text

I need to create a macro to delete all rows where column A has text. Can
anyone tell me any easy way to do this?
  #2   Report Post  
JE McGimpsey
 
Posts: n/a
Default

One way:

Public Sub DeleteRowsWithTextInColumnA()
On Error Resume Next 'in case no text
Columns(1).SpecialCells( _
xlCellTypeConstants, xlTextValues).EntireRow.Delete
On Error GoTo 0
End Sub


In article ,
"D Hafer - TFE" wrote:

I need to create a macro to delete all rows where column A has text. Can
anyone tell me any easy way to do this?

  #3   Report Post  
D Hafer - TFE
 
Posts: n/a
Default

Actually, I'd like to remove the rows where column A is blank also, let's say
for just the first 300 rows in a sheet. How would this code change?


"JE McGimpsey" wrote:

One way:

Public Sub DeleteRowsWithTextInColumnA()
On Error Resume Next 'in case no text
Columns(1).SpecialCells( _
xlCellTypeConstants, xlTextValues).EntireRow.Delete
On Error GoTo 0
End Sub


In article ,
"D Hafer - TFE" wrote:

I need to create a macro to delete all rows where column A has text. Can
anyone tell me any easy way to do this?


  #4   Report Post  
JE McGimpsey
 
Posts: n/a
Default

One way:

Public Sub DeleteRowsWithTextOrBlanksInA1ToA300()
Dim rDelete
On Error Resume Next 'in case no text or blanks
With Range("A1:A300")
Set rDelete = .SpecialCells( _
xlCellTypeConstants, xlTextValues)
If rDelete Is Nothing Then
Set rDelete = .SpecialCells(xlCellTypeBlanks)
Else
Set rDelete = Union(rDelete, _
.SpecialCells(xlCellTypeBlanks))
End If
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
End With
On Error GoTo 0
End Sub




In article ,
"D Hafer - TFE" wrote:

Actually, I'd like to remove the rows where column A is blank also, let's say
for just the first 300 rows in a sheet. How would this code change?


"JE McGimpsey" wrote:

One way:

Public Sub DeleteRowsWithTextInColumnA()
On Error Resume Next 'in case no text
Columns(1).SpecialCells( _
xlCellTypeConstants, xlTextValues).EntireRow.Delete
On Error GoTo 0
End Sub


In article ,
"D Hafer - TFE" wrote:

I need to create a macro to delete all rows where column A has text. Can
anyone tell me any easy way to do this?


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
Formulas dealing with text data Bagia Excel Worksheet Functions 6 June 20th 05 10:29 PM
Selective deletion of rows containing certain text. Colin Hayes Excel Worksheet Functions 9 June 15th 05 10:41 PM
generate multiple rows based on cell value Theresa Excel Worksheet Functions 0 May 25th 05 11:18 PM
Sort or Filter option? Mcobra41 Excel Worksheet Functions 3 February 23rd 05 07:22 PM
Formula to compare multiple rows values based on another column? Murph Excel Worksheet Functions 4 February 21st 05 02:44 AM


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