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 / Programming / February 2007

Tip: Looking for answers? Try searching our database.

select rows and delete based on criteria

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
steven - 15 Feb 2007 14:58 GMT
hi sorry for being a pain...

I have a worksheet with data from column A to E and from rows 1 to (lets
say) 5000. I want a macro that serches for rows that have "2" in column C and
are NOT BLANK, then select all thses rows from column A to IV (not just A to
E) and then delete them (shiftng all other rows up but i think this happens
automatically. How can I do this.

Also in the resulting table I want to select all remaianing rows (again from
A to IV).

thank you.
Ron de Bruin - 15 Feb 2007 15:01 GMT
Hi Steven

Start here
http://www.rondebruin.nl/delete.htm

Signature

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

> hi sorry for being a pain...
>
[quoted text clipped - 8 lines]
>
> thank you.
steven - 15 Feb 2007 15:30 GMT
this is what i made out  of the webpage

Sub deleterows2crtr()
ElseIf .Cells(Lrow, "E").Value = "2" And _
      .Cells(Lrow, "G").Value <> 0 Then .Rows(Lrow).Delete
End Sub

it dosent seem to work though. Invalid criteria or something. Can you help
out?

S.

> Hi Steven
>
[quoted text clipped - 13 lines]
> >
> > thank you.
Ron de Bruin - 15 Feb 2007 15:44 GMT
Hi Steven

Try this

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 = 5000

       For Lrow = EndRow To StartRow Step -1

           If .Cells(Lrow, "E").Value = 2 And _
              .Cells(Lrow, "G").Value <> 0 Then .Rows(Lrow).Delete

       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

> this is what i made out  of the webpage
>
[quoted text clipped - 25 lines]
>> >
>> > thank you.
steven - 15 Feb 2007 15:47 GMT
niewbe me... never mind I figured t out!

thank you!

> Hi Steven
>
[quoted text clipped - 13 lines]
> >
> > thank you.
 
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.