PC Review


Reply
Thread Tools Rate Thread

delete rows that contain ********* ?

 
 
=?Utf-8?B?c3ZlcnJl?=
Guest
Posts: n/a
 
      2nd Nov 2006
Hi

I have tried to delete rows that contain ******** in col no 3.
with below code. problem is that xl thinks it is wildcards and deletes
everything....
.. Solvable??

Worksheets("FRB").Select
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
Dim rng As Range
Columns(3).Replace What:="******** ", _
Replacement:="=na()", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False
On Error Resume Next
Set rng = Columns(3).SpecialCells(xlFormulas, xlErrors)
On Error GoTo 0
If Not rng Is Nothing Then
rng.EntireRow.delete
End If
With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With

End Sub
 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      2nd Nov 2006
Try:

Sub star_killer()
Dim r As Range, rr As Range
Set r = ActiveSheet.UsedRange
n = nLastRow + r.Rows.Count + r.Row - 1
For i = 1 To n
If Cells(i, 3).Value = "********" Then
If rr Is Nothing Then
Set rr = Cells(i, 3)
Else
Set rr = Union(rr, Cells(i, 3))
End If
End If
Next
If rr Is Nothing Then
Else
rr.EntireRow.Delete
End If
End Sub
--
Gary's Student


"sverre" wrote:

> Hi
>
> I have tried to delete rows that contain ******** in col no 3.
> with below code. problem is that xl thinks it is wildcards and deletes
> everything....
> . Solvable??
>
> Worksheets("FRB").Select
> With Application
> .Calculation = xlManual
> .MaxChange = 0.001
> End With
> Dim rng As Range
> Columns(3).Replace What:="******** ", _
> Replacement:="=na()", LookAt:=xlWhole, _
> SearchOrder:=xlByRows, MatchCase:=False
> On Error Resume Next
> Set rng = Columns(3).SpecialCells(xlFormulas, xlErrors)
> On Error GoTo 0
> If Not rng Is Nothing Then
> rng.EntireRow.delete
> End If
> With Application
> .Calculation = xlAutomatic
> .MaxChange = 0.001
> End With
>
> End Sub

 
Reply With Quote
 
=?Utf-8?B?c3ZlcnJl?=
Guest
Posts: n/a
 
      6th Nov 2006
Hi Gary

No, it does not work. The stars are not killed. Nothing is actually affected.
Do I send you the file so you can check the code?

Br Sverre

"Gary''s Student" skrev:

> Try:
>
> Sub star_killer()
> Dim r As Range, rr As Range
> Set r = ActiveSheet.UsedRange
> n = nLastRow + r.Rows.Count + r.Row - 1
> For i = 1 To n
> If Cells(i, 3).Value = "********" Then
> If rr Is Nothing Then
> Set rr = Cells(i, 3)
> Else
> Set rr = Union(rr, Cells(i, 3))
> End If
> End If
> Next
> If rr Is Nothing Then
> Else
> rr.EntireRow.Delete
> End If
> End Sub
> --
> Gary's Student
>
>
> "sverre" wrote:
>
> > Hi
> >
> > I have tried to delete rows that contain ******** in col no 3.
> > with below code. problem is that xl thinks it is wildcards and deletes
> > everything....
> > . Solvable??
> >
> > Worksheets("FRB").Select
> > With Application
> > .Calculation = xlManual
> > .MaxChange = 0.001
> > End With
> > Dim rng As Range
> > Columns(3).Replace What:="******** ", _
> > Replacement:="=na()", LookAt:=xlWhole, _
> > SearchOrder:=xlByRows, MatchCase:=False
> > On Error Resume Next
> > Set rng = Columns(3).SpecialCells(xlFormulas, xlErrors)
> > On Error GoTo 0
> > If Not rng Is Nothing Then
> > rng.EntireRow.delete
> > End If
> > With Application
> > .Calculation = xlAutomatic
> > .MaxChange = 0.001
> > End With
> >
> > End Sub

 
Reply With Quote
 
Kweenie
Guest
Posts: n/a
 
      6th Nov 2006
Hi Sverre

In my opinion both codes work fine.
but in your code there is a space behind the stars.
I don't know if you noticed that.

Piet


sverre schreef:

> Hi Gary
>
> No, it does not work. The stars are not killed. Nothing is actually affected.
> Do I send you the file so you can check the code?
>
> Br Sverre
>
> "Gary''s Student" skrev:
>
> > Try:
> >
> > Sub star_killer()
> > Dim r As Range, rr As Range
> > Set r = ActiveSheet.UsedRange
> > n = nLastRow + r.Rows.Count + r.Row - 1
> > For i = 1 To n
> > If Cells(i, 3).Value = "********" Then
> > If rr Is Nothing Then
> > Set rr = Cells(i, 3)
> > Else
> > Set rr = Union(rr, Cells(i, 3))
> > End If
> > End If
> > Next
> > If rr Is Nothing Then
> > Else
> > rr.EntireRow.Delete
> > End If
> > End Sub
> > --
> > Gary's Student
> >
> >
> > "sverre" wrote:
> >
> > > Hi
> > >
> > > I have tried to delete rows that contain ******** in col no 3.
> > > with below code. problem is that xl thinks it is wildcards and deletes
> > > everything....
> > > . Solvable??
> > >
> > > Worksheets("FRB").Select
> > > With Application
> > > .Calculation = xlManual
> > > .MaxChange = 0.001
> > > End With
> > > Dim rng As Range
> > > Columns(3).Replace What:="******** ", _
> > > Replacement:="=na()", LookAt:=xlWhole, _
> > > SearchOrder:=xlByRows, MatchCase:=False
> > > On Error Resume Next
> > > Set rng = Columns(3).SpecialCells(xlFormulas, xlErrors)
> > > On Error GoTo 0
> > > If Not rng Is Nothing Then
> > > rng.EntireRow.delete
> > > End If
> > > With Application
> > > .Calculation = xlAutomatic
> > > .MaxChange = 0.001
> > > End With
> > >
> > > End Sub


 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      6th Nov 2006
No need to send me the file. Someone else in the Center pointed out that I
must need new glasses. My code (erroneously) looked for 8 *s.

Your code looked for 8 *s followed by a single space. Try my code again
with a single space after the last *
--
Gary's Student


"sverre" wrote:

> Hi Gary
>
> No, it does not work. The stars are not killed. Nothing is actually affected.
> Do I send you the file so you can check the code?
>
> Br Sverre
>
> "Gary''s Student" skrev:
>
> > Try:
> >
> > Sub star_killer()
> > Dim r As Range, rr As Range
> > Set r = ActiveSheet.UsedRange
> > n = nLastRow + r.Rows.Count + r.Row - 1
> > For i = 1 To n
> > If Cells(i, 3).Value = "********" Then
> > If rr Is Nothing Then
> > Set rr = Cells(i, 3)
> > Else
> > Set rr = Union(rr, Cells(i, 3))
> > End If
> > End If
> > Next
> > If rr Is Nothing Then
> > Else
> > rr.EntireRow.Delete
> > End If
> > End Sub
> > --
> > Gary's Student
> >
> >
> > "sverre" wrote:
> >
> > > Hi
> > >
> > > I have tried to delete rows that contain ******** in col no 3.
> > > with below code. problem is that xl thinks it is wildcards and deletes
> > > everything....
> > > . Solvable??
> > >
> > > Worksheets("FRB").Select
> > > With Application
> > > .Calculation = xlManual
> > > .MaxChange = 0.001
> > > End With
> > > Dim rng As Range
> > > Columns(3).Replace What:="******** ", _
> > > Replacement:="=na()", LookAt:=xlWhole, _
> > > SearchOrder:=xlByRows, MatchCase:=False
> > > On Error Resume Next
> > > Set rng = Columns(3).SpecialCells(xlFormulas, xlErrors)
> > > On Error GoTo 0
> > > If Not rng Is Nothing Then
> > > rng.EntireRow.delete
> > > End If
> > > With Application
> > > .Calculation = xlAutomatic
> > > .MaxChange = 0.001
> > > End With
> > >
> > > End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofil on variable rows, delete extract and show remaining rows 1plane Microsoft Excel Programming 3 17th Nov 2009 10:49 AM
Hpw do I delete multiple empty rows found between filled rows? Bill Microsoft Excel Worksheet Functions 1 15th Nov 2009 12:52 AM
Copy pasting Rows, but need to Delete any Shapes/Pictures that are within copied rows Corey Microsoft Excel Programming 2 1st Aug 2007 02:02 AM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Microsoft Excel Worksheet Functions 0 13th Dec 2006 01:25 AM
Delete rows with numeric values, leave rows with text =?Utf-8?B?R1NwbGluZQ==?= Microsoft Excel Programming 5 11th Oct 2005 12:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:10 PM.