Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Delete Row based on cell contents

Hi. Is it possible to delete the entire row if the contents of cellA in
that row contains a "/"?

So, I'd like to scan an entire sheet, and delete all rows that have a "/"
somewhere within the cell contents in column A of each row. Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Delete Row based on cell contents

How well do you know vba? Look in vba help index for FINDNEXT

--
Don Guillett
SalesAid Software

"Steph" wrote in message
...
Hi. Is it possible to delete the entire row if the contents of cellA in
that row contains a "/"?

So, I'd like to scan an entire sheet, and delete all rows that have a "/"
somewhere within the cell contents in column A of each row. Thanks!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Delete Row based on cell contents

or this should look at fewer cells than for/next loop

Sub findsumifslash()
With Cells
On Error Resume Next
Set c = .Find("/", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If Not c Is Nothing Then
firstaddress = c.Address
Do
Rows(c.Row).ClearContents
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstaddress
End If
End With
Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete
End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
How well do you know vba? Look in vba help index for FINDNEXT

--
Don Guillett
SalesAid Software

"Steph" wrote in message
...
Hi. Is it possible to delete the entire row if the contents of cellA in
that row contains a "/"?

So, I'd like to scan an entire sheet, and delete all rows that have a

"/"
somewhere within the cell contents in column A of each row. Thanks!






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete Row based on cell contents

Hi Don,

Columns("A").SpecialCells
(xlCellTypeBlanks).EntireRow.Delete


What if there were legitimate blank cells or the slash character were not
located in any cell?

---
Regards,
Norman



"Don Guillett" wrote in message
...
or this should look at fewer cells than for/next loop

Sub findsumifslash()
With Cells
On Error Resume Next
Set c = .Find("/", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If Not c Is Nothing Then
firstaddress = c.Address
Do
Rows(c.Row).ClearContents
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstaddress
End If
End With
Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete
End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
How well do you know vba? Look in vba help index for FINDNEXT

--
Don Guillett
SalesAid Software

"Steph" wrote in message
...
Hi. Is it possible to delete the entire row if the contents of cellA
in
that row contains a "/"?

So, I'd like to scan an entire sheet, and delete all rows that have a

"/"
somewhere within the cell contents in column A of each row. Thanks!








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Delete Row based on cell contents

or

Sub findsumifslash_A()
With Cells
On Error Resume Next
Set c = .Find("/", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If Not c Is Nothing Then
firstaddress = c.Address
Do
mystr = mystr & "," & c.Address
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstaddress
End If
End With
Range(Right(mystr, Len(mystr) - 1)).EntireRow.Delete
End Sub

--
Don Guillett
SalesAid Software

"Norman Jones" wrote in message
...
Hi Don,

Columns("A").SpecialCells
(xlCellTypeBlanks).EntireRow.Delete


What if there were legitimate blank cells or the slash character were not
located in any cell?

---
Regards,
Norman



"Don Guillett" wrote in message
...
or this should look at fewer cells than for/next loop

Sub findsumifslash()
With Cells
On Error Resume Next
Set c = .Find("/", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If Not c Is Nothing Then
firstaddress = c.Address
Do
Rows(c.Row).ClearContents
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstaddress
End If
End With
Columns("A").SpecialCells(xlCellTypeBlanks).Entire Row.Delete
End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
How well do you know vba? Look in vba help index for FINDNEXT

--
Don Guillett
SalesAid Software

"Steph" wrote in message
...
Hi. Is it possible to delete the entire row if the contents of cellA
in
that row contains a "/"?

So, I'd like to scan an entire sheet, and delete all rows that have a

"/"
somewhere within the cell contents in column A of each row. Thanks!










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Delete Row based on cell contents

Hi Steph,

Try:
'==============
Public Sub DeleteRange()
Dim rng As Range
Dim rcell As Range
Dim delRng As Range
Dim WB As Workbook
Dim SH As Worksheet
Dim LRow As Long
Dim CalcMode As Long
Const sStr As String = "/" '<<==== CHANGE

Set WB = ActiveWorkbook '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE

LRow = SH.Cells(Rows.Count, "A").End(xlUp).Row

Set rng = SH.Range("A1").Resize(LRow) '<<== CHANGE

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

For Each rcell In rng.Cells
If InStr(1, rcell.Value, sStr, vbTextCompare) Then
If delRng Is Nothing Then
Set delRng = rcell
Else
Set delRng = Union(rcell, delRng)
End If
End If
Next rcell

If Not delRng Is Nothing Then
delRng.EntireRow.Delete
Else
'nothing found, do nothing
End If

With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With

End Sub
'<<================

---
Regards,
Norman



"Steph" wrote in message
...
Hi. Is it possible to delete the entire row if the contents of cellA in
that row contains a "/"?

So, I'd like to scan an entire sheet, and delete all rows that have a "/"
somewhere within the cell contents in column A of each row. Thanks!




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
Delete ROW based on Cell Contents HeatherJ Excel Discussion (Misc queries) 4 February 11th 10 04:25 PM
Delete cell contents Rob[_4_] Excel Discussion (Misc queries) 7 April 10th 07 12:34 PM
Delete row based on contents of cell AndyG Excel Discussion (Misc queries) 6 November 17th 05 10:08 PM
Delete/clear a cell based on another cells contents jademaddy Excel Programming 2 May 19th 05 06:15 PM


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