Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2006

Tip: Looking for answers? Try searching our database.

Delete Rows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bernie - 28 Dec 2006 15:42 GMT
I would like to be able to delete a row with a name in it based on a
cell with that name from another cell in a different worksheet.  Any
ideas?

Thanks,
Bernie
Ron de Bruin - 28 Dec 2006 21:33 GMT
Hi Bernie

This example loop through row 1 - 100 on the activesheet and if the value in A is the same as in
Sheets("Yoursheet").Range("A1").Value in delete the row

Maybe you can use a Autofilter if you have many rows (faster)
See this page for more info
http://www.rondebruin.nl/delete.htm

Sub Example2()
   Dim Lrow As Long
   Dim CalcMode As Long
   Dim ViewMode As Long
   Dim StartRow As Long
   Dim EndRow As Long

   With Application
       CalcMode = .Calculation
       .Calculation = xlCalculationManual
       .ScreenUpdating = False
   End With

   ViewMode = ActiveWindow.View
   ActiveWindow.View = xlNormalView

   With ActiveSheet
       .DisplayPageBreaks = False
       StartRow = 1
       EndRow = 100

       For Lrow = EndRow To StartRow Step -1

           If IsError(.Cells(Lrow, "A").Value) Then
               'Do nothing, This avoid a error if there is a error in the cell

           ElseIf .Cells(Lrow, "A").Value = Sheets("Yoursheet").Range("A1").Value Then .Rows(Lrow).Delete
               'This will delete each row with the Value "ron" in Column A, case sensitive.

           End If
       Next
   End With

   ActiveWindow.View = ViewMode
   With Application
       .ScreenUpdating = True
       .Calculation = CalcMode
   End With

End Sub

Signature

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm

>I would like to be able to delete a row with a name in it based on a
> cell with that name from another cell in a different worksheet.  Any
> ideas?
>
> Thanks,
> Bernie

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.