Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using VBA to delete certain worksheets rows

Hi everyone

I have a large worksheet that contains a large amount of records wit
the same values that are not relevant and need deleting. I am using th
following code that does not work.

Can anyone please help

Sub Macro2()
If ActiveCell = ("n/a") Then
EntireRow.Delete
End If
ActiveCell.Offset(1, 0).Select

End Sub

I would also like the macro to stop when it reaches a cell that doe
not contain any value

THANK YO

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Using VBA to delete certain worksheets rows

Hi Avilla,

One way:

Sub Tester()
Dim Lastcell As Range
Dim i As Long

Application.DisplayAlerts = False

Set Lastcell = Cells(Rows.Count, "A")

For i = Lastcell.Row To 1 Step -1
If Cells(i, 1).Value = ("n/a") Then
Cells(i, 1).EntireRow.Delete
End If
Next i
Application.DisplayAlerts = True
End Sub

---
Regards,
Norman



"avilla " wrote in message
...
Hi everyone

I have a large worksheet that contains a large amount of records with
the same values that are not relevant and need deleting. I am using the
following code that does not work.

Can anyone please help

Sub Macro2()
If ActiveCell = ("n/a") Then
EntireRow.Delete
End If
ActiveCell.Offset(1, 0).Select

End Sub

I would also like the macro to stop when it reaches a cell that does
not contain any value

THANK YOU


---
Message posted from http://www.ExcelForum.com/



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
Delete all rows below certain value on multiple worksheets? [email protected] Excel Discussion (Misc queries) 1 January 4th 08 05:51 PM
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents BenS Excel Discussion (Misc queries) 3 June 29th 07 12:20 AM
Add or Delete Rows in Protected worksheets NH Excel Discussion (Misc queries) 0 March 16th 06 05:15 PM
insert or delete rows across multiple worksheets? BobW Excel Discussion (Misc queries) 1 February 16th 06 05:02 PM
delete rows from multiple worksheets dckrause Excel Worksheet Functions 1 June 1st 05 03:24 AM


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