Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Macro For Deleting Cells Containing A Number

jim:

thanks for that tip, and the compliment. don't know how good it is, i just
muddle my way through most of the time

thanks again

--


Gary


"JMay" wrote in message
news:J5yyf.138948$WH.98313@dukeread01...
Another modification (to speed it up) would be to after each trip Up the
column and if deletion takes place have
the macro recalculate the "lastrow" integer. At present, it is agter each
trip Up the column returning to Row 11 when in fact there is no data in
row 11, 10, 9, 8 --- if 4 rows have already been deleted.
I changed your reference to lastrow to BegLastRow
and then put within the For Next statement a Recalculation
statement and a new Reference NewLastRow to
eliminate revisiting already deleted rows.

Sub Foo()
Dim arr As Variant
Dim i As Long
Dim BlastRow As Long
Dim rng As Range
Dim cell As Range
Dim c As Long
arr = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
BegLastRow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A1:A" & BegLastRow)
For i = LBound(arr) To UBound(arr)
Application.Calculate
NewLastRow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
c = NewLastRow
Do While c 0
If InStr(1, Range("a" & c), arr(i)) Then
Rows(c).EntireRow.Delete
Else
End If
c = c - 1
Loop
Next
End Sub

Logically, this involves fewer passes. Gary Did an excellent job on this
incidently; Thanks Gary...

HTH,

Jim May

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
adding this would make it a little faster

Application.ScreenUpdating = False

code

Application.ScreenUpdating = true
--


Gary


"brazen234"
wrote in message
...

-Yngve
I ran your macro but it did not delete the rows with numbers. The list
was the same after running it.

-Gary Keramidas
Thanks, your macro does work! But can it be faster ? My lists are in
the tens of thousands.

-Toppers
Thanks but there are also occurences of the last character being alpha
with numbers inbetween.


--
brazen234
------------------------------------------------------------------------
brazen234's Profile:
http://www.excelforum.com/member.php...fo&userid=9952
View this thread:
http://www.excelforum.com/showthread...hreadid=501478







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
MACRO HELP - deleting rows containing a range of blank cells DavidHawes Excel Discussion (Misc queries) 9 February 26th 07 03:40 PM
Need Help Creating a Macro to Multiply Cells by a Constant Number Tyn Excel Discussion (Misc queries) 5 February 12th 07 10:40 AM
Macro to add cells from unknown number of files rich.s Excel Programming 0 August 4th 05 03:39 PM
Deleting Hyphens or Dashes from multiple cells without deleting the remaining content rmaloy Excel Programming 5 February 9th 04 01:59 AM
deleting variable number of rows Nick Excel Programming 1 October 29th 03 04:31 PM


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