#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default LOOPS IN MACROS

Hello

I'm trying to loop the below macro but having no luck.

I want in excel to find a certain word e.g. NOTNEEDED and delete whole line
then repeat until none left.

Any help gratefully accepted.

Range("A1").Select

Dim FoundCell As Range
With Worksheets("StockSheet")

Range("A1").Select

Set FoundCell = .Cells.Find(What:="NOTNEEDED", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then

Else

FoundCell.EntireRow.Delete
End If

End With
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,123
Default LOOPS IN MACROS

Hi Heather

See
http://www.rondebruin.nl/delete.htm

If you want to use Find try
http://www.rondebruin.nl/delete.htm#Find

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Heather O'Malley" wrote in message . ..
Hello

I'm trying to loop the below macro but having no luck.

I want in excel to find a certain word e.g. NOTNEEDED and delete whole line
then repeat until none left.

Any help gratefully accepted.

Range("A1").Select

Dim FoundCell As Range
With Worksheets("StockSheet")

Range("A1").Select

Set FoundCell = .Cells.Find(What:="NOTNEEDED", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then

Else

FoundCell.EntireRow.Delete
End If

End With



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default LOOPS IN MACROS

This:

Sub cleanup()
Dim r As Range
Set r = ActiveSheet.UsedRange
nLastRoW = r.Rows.Count + r.Row - 1

For i = nLastRoW To 1 Step -1
If Cells(i, "A").Value = "NOTNEEDED" Then
Cells(i, "A").EntireRow.Delete
End If
Next
End Sub

will scan thru column A and remove rows with the match word.
--
Gary''s Student


"Heather O'Malley" wrote:

Hello

I'm trying to loop the below macro but having no luck.

I want in excel to find a certain word e.g. NOTNEEDED and delete whole line
then repeat until none left.

Any help gratefully accepted.

Range("A1").Select

Dim FoundCell As Range
With Worksheets("StockSheet")

Range("A1").Select

Set FoundCell = .Cells.Find(What:="NOTNEEDED", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then

Else

FoundCell.EntireRow.Delete
End If

End With

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
Deleting phantom macros [email protected] Setting up and Configuration of Excel 2 September 8th 06 11:47 AM
Hide Macro's in Toolbar / Macro's list sparx Excel Discussion (Misc queries) 2 May 6th 06 08:53 PM
how do I run excel 4.0 macros on excel 2000 RodolfoDallas Excel Discussion (Misc queries) 1 March 12th 06 03:14 AM
Excel crashes while opening excel file imbeddied with macros ct2147 Excel Discussion (Misc queries) 0 December 30th 05 09:05 PM
Transferring toolbars and macros to other computers Darrell Excel Discussion (Misc queries) 1 January 19th 05 12:21 AM


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