Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default SpecialCells Value=0??

Excel XP, Win XP
Helping an OP.
The OP has a long column (5,000 - 10,000 rows) of mathematical formulas. A
number of the values are "0" (numerical, not text).
The OP wants to delete all the rows that have "0" in that column.
I can loop through all the cells, from the bottom up, with something like:
If TheRng(c).Value = 0 Then 'delete the row
This will take a while because the column is long.
My question:
Is there any way I can use something like:
TheRng.SpecialCells(xlCellTypeConstants, xlNumbers = 0)
so that I can operate on that range in one operation instead of looping?
Thanks for your time. Otto


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default SpecialCells Value=0??

Sub DeleteRows()
Dim iLastRow As Long
Dim rng As Range

With ActiveSheet
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Columns("A:A").AutoFilter
.Range("A1:A" & iLastRow).AutoFilter Field:=1, _
Criteria1:="=0", _
Operator:=xlAnd
Set rng = .Range("A2:A" & iLastRow).SpecialCells(xlCellTypeVisible)
rng.EntireRow.Delete
.Columns("A:A").AutoFilter
End With

End Sub


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Otto Moehrbach" wrote in message
...
Excel XP, Win XP
Helping an OP.
The OP has a long column (5,000 - 10,000 rows) of mathematical formulas.
A number of the values are "0" (numerical, not text).
The OP wants to delete all the rows that have "0" in that column.
I can loop through all the cells, from the bottom up, with something like:
If TheRng(c).Value = 0 Then 'delete the row
This will take a while because the column is long.
My question:
Is there any way I can use something like:
TheRng.SpecialCells(xlCellTypeConstants, xlNumbers = 0)
so that I can operate on that range in one operation instead of looping?
Thanks for your time. Otto



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default SpecialCells Value=0??

Thanks Bob. That's better than looping. Otto
"Bob Phillips" wrote in message
...
Sub DeleteRows()
Dim iLastRow As Long
Dim rng As Range

With ActiveSheet
iLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Columns("A:A").AutoFilter
.Range("A1:A" & iLastRow).AutoFilter Field:=1, _
Criteria1:="=0", _
Operator:=xlAnd
Set rng = .Range("A2:A" & iLastRow).SpecialCells(xlCellTypeVisible)
rng.EntireRow.Delete
.Columns("A:A").AutoFilter
End With

End Sub


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Otto Moehrbach" wrote in message
...
Excel XP, Win XP
Helping an OP.
The OP has a long column (5,000 - 10,000 rows) of mathematical formulas.
A number of the values are "0" (numerical, not text).
The OP wants to delete all the rows that have "0" in that column.
I can loop through all the cells, from the bottom up, with something
like:
If TheRng(c).Value = 0 Then 'delete the row
This will take a while because the column is long.
My question:
Is there any way I can use something like:
TheRng.SpecialCells(xlCellTypeConstants, xlNumbers = 0)
so that I can operate on that range in one operation instead of looping?
Thanks for your time. Otto





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
SpecialCells help Graham Y Excel Programming 2 October 11th 06 05:16 PM
SpecialCells mike Excel Programming 4 June 8th 06 01:50 AM
SpecialCells Peter Excel Programming 3 April 12th 06 02:03 PM
Specialcells Bruno Uato Charts and Charting in Excel 0 October 7th 05 07:42 PM
SpecialCells and UsedRange Norm[_5_] Excel Programming 2 April 1st 04 06:53 PM


All times are GMT +1. The time now is 04:38 PM.

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"