PC Review


Reply
Thread Tools Rate Thread

Delete row 2 cell criteria

 
 
Steve Kellogg
Guest
Posts: n/a
 
      12th Aug 2008
I have a spread sheet that changes nightly. In column D every cell has a
number. In column E there are either notes or it is blank. What I am looking
to do is delete any row, where the number in column D is less than 96 AND
there are notes in column E.

So if D is higher than 96 and/or E is blank, I want to keep that row, delete
all others. On any given day I may have as few as 50 rows up to 250 rows.
Thanks in advance for any help.
--
Thanks Steve
 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      12th Aug 2008
you can give this a try and see if it meets your needs:

Sub dlete_rows()
Dim ws As Worksheet
Dim i As Long
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "D").End(xlUp).Row

For i = lastrow To 2 Step -1
With ws.Range("D" & i)
If .Value < 96 And .Offset(, 1).Value > "" Then
.EntireRow.Delete
End If
End With
Next
End Sub

--


Gary


"Steve Kellogg" <(E-Mail Removed)> wrote in message
news:05B11510-B81C-4FD6-80F7-(E-Mail Removed)...
>I have a spread sheet that changes nightly. In column D every cell has a
> number. In column E there are either notes or it is blank. What I am looking
> to do is delete any row, where the number in column D is less than 96 AND
> there are notes in column E.
>
> So if D is higher than 96 and/or E is blank, I want to keep that row, delete
> all others. On any given day I may have as few as 50 rows up to 250 rows.
> Thanks in advance for any help.
> --
> Thanks Steve



 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      12th Aug 2008
or this:

Sub dlete_rows()
Dim ws As Worksheet
Dim i As Long
Dim lastrow As Long
Set ws = Worksheets("Sheet1")
lastrow = ws.Cells(Rows.Count, "D").End(xlUp).Row

For i = lastrow To 2 Step -1
With ws.Range("D" & i)
If .Value < 96 And len(.Offset(, 1).Value) =0 Then
.EntireRow.Delete
End If
End With
Next
End Sub

--


Gary


"Gary Keramidas" <GKeramidasATmsn.com> wrote in message
news:%23L2uPHE$(E-Mail Removed)...
> you can give this a try and see if it meets your needs:
>
> Sub dlete_rows()
> Dim ws As Worksheet
> Dim i As Long
> Dim lastrow As Long
> Set ws = Worksheets("Sheet1")
> lastrow = ws.Cells(Rows.Count, "D").End(xlUp).Row
>
> For i = lastrow To 2 Step -1
> With ws.Range("D" & i)
> If .Value < 96 And .Offset(, 1).Value > "" Then
> .EntireRow.Delete
> End If
> End With
> Next
> End Sub
>
> --
>
>
> Gary
>
>
> "Steve Kellogg" <(E-Mail Removed)> wrote in message
> news:05B11510-B81C-4FD6-80F7-(E-Mail Removed)...
>>I have a spread sheet that changes nightly. In column D every cell has a
>> number. In column E there are either notes or it is blank. What I am looking
>> to do is delete any row, where the number in column D is less than 96 AND
>> there are notes in column E.
>>
>> So if D is higher than 96 and/or E is blank, I want to keep that row, delete
>> all others. On any given day I may have as few as 50 rows up to 250 rows.
>> Thanks in advance for any help.
>> --
>> Thanks Steve

>
>



 
Reply With Quote
 
Steve Kellogg
Guest
Posts: n/a
 
      12th Aug 2008
Gary THANK YOU!!!!! My only other question would be can I change "sheet1" to
be any sheet I am on? The sheet name is different each day.

Again, I can't thank you enough, it worked perfect!
--
Thanks Steve


"Gary Keramidas" wrote:

> you can give this a try and see if it meets your needs:
>
> Sub dlete_rows()
> Dim ws As Worksheet
> Dim i As Long
> Dim lastrow As Long
> Set ws = Worksheets("Sheet1")
> lastrow = ws.Cells(Rows.Count, "D").End(xlUp).Row
>
> For i = lastrow To 2 Step -1
> With ws.Range("D" & i)
> If .Value < 96 And .Offset(, 1).Value > "" Then
> .EntireRow.Delete
> End If
> End With
> Next
> End Sub
>
> --
>
>
> Gary
>
>
> "Steve Kellogg" <(E-Mail Removed)> wrote in message
> news:05B11510-B81C-4FD6-80F7-(E-Mail Removed)...
> >I have a spread sheet that changes nightly. In column D every cell has a
> > number. In column E there are either notes or it is blank. What I am looking
> > to do is delete any row, where the number in column D is less than 96 AND
> > there are notes in column E.
> >
> > So if D is higher than 96 and/or E is blank, I want to keep that row, delete
> > all others. On any given day I may have as few as 50 rows up to 250 rows.
> > Thanks in advance for any help.
> > --
> > Thanks Steve

>
>
>

 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      12th Aug 2008
just change this:
Set ws = Worksheets("Sheet1")

to this:
Set ws = ActiveSheet

and it will run on the active sheet

or this:
Set ws = Worksheets(1)

if it's always the first sheet

--


Gary


"Steve Kellogg" <(E-Mail Removed)> wrote in message
news:0B8CB885-913B-42B8-A252-(E-Mail Removed)...
> Gary THANK YOU!!!!! My only other question would be can I change "sheet1" to
> be any sheet I am on? The sheet name is different each day.
>
> Again, I can't thank you enough, it worked perfect!
> --
> Thanks Steve
>
>
> "Gary Keramidas" wrote:
>
>> you can give this a try and see if it meets your needs:
>>
>> Sub dlete_rows()
>> Dim ws As Worksheet
>> Dim i As Long
>> Dim lastrow As Long
>> Set ws = Worksheets("Sheet1")
>> lastrow = ws.Cells(Rows.Count, "D").End(xlUp).Row
>>
>> For i = lastrow To 2 Step -1
>> With ws.Range("D" & i)
>> If .Value < 96 And .Offset(, 1).Value > "" Then
>> .EntireRow.Delete
>> End If
>> End With
>> Next
>> End Sub
>>
>> --
>>
>>
>> Gary
>>
>>
>> "Steve Kellogg" <(E-Mail Removed)> wrote in message
>> news:05B11510-B81C-4FD6-80F7-(E-Mail Removed)...
>> >I have a spread sheet that changes nightly. In column D every cell has a
>> > number. In column E there are either notes or it is blank. What I am
>> > looking
>> > to do is delete any row, where the number in column D is less than 96 AND
>> > there are notes in column E.
>> >
>> > So if D is higher than 96 and/or E is blank, I want to keep that row,
>> > delete
>> > all others. On any given day I may have as few as 50 rows up to 250 rows.
>> > Thanks in advance for any help.
>> > --
>> > Thanks Steve

>>
>>
>>



 
Reply With Quote
 
Steve Kellogg
Guest
Posts: n/a
 
      12th Aug 2008
Works perfect. Thanks again Gary.
--
Thanks Steve


"Gary Keramidas" wrote:

> just change this:
> Set ws = Worksheets("Sheet1")
>
> to this:
> Set ws = ActiveSheet
>
> and it will run on the active sheet
>
> or this:
> Set ws = Worksheets(1)
>
> if it's always the first sheet
>
> --
>
>
> Gary
>
>
> "Steve Kellogg" <(E-Mail Removed)> wrote in message
> news:0B8CB885-913B-42B8-A252-(E-Mail Removed)...
> > Gary THANK YOU!!!!! My only other question would be can I change "sheet1" to
> > be any sheet I am on? The sheet name is different each day.
> >
> > Again, I can't thank you enough, it worked perfect!
> > --
> > Thanks Steve
> >
> >
> > "Gary Keramidas" wrote:
> >
> >> you can give this a try and see if it meets your needs:
> >>
> >> Sub dlete_rows()
> >> Dim ws As Worksheet
> >> Dim i As Long
> >> Dim lastrow As Long
> >> Set ws = Worksheets("Sheet1")
> >> lastrow = ws.Cells(Rows.Count, "D").End(xlUp).Row
> >>
> >> For i = lastrow To 2 Step -1
> >> With ws.Range("D" & i)
> >> If .Value < 96 And .Offset(, 1).Value > "" Then
> >> .EntireRow.Delete
> >> End If
> >> End With
> >> Next
> >> End Sub
> >>
> >> --
> >>
> >>
> >> Gary
> >>
> >>
> >> "Steve Kellogg" <(E-Mail Removed)> wrote in message
> >> news:05B11510-B81C-4FD6-80F7-(E-Mail Removed)...
> >> >I have a spread sheet that changes nightly. In column D every cell has a
> >> > number. In column E there are either notes or it is blank. What I am
> >> > looking
> >> > to do is delete any row, where the number in column D is less than 96 AND
> >> > there are notes in column E.
> >> >
> >> > So if D is higher than 96 and/or E is blank, I want to keep that row,
> >> > delete
> >> > all others. On any given day I may have as few as 50 rows up to 250 rows.
> >> > Thanks in advance for any help.
> >> > --
> >> > Thanks Steve
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete rows where 1st 3 characters in a cell DO NOT meet criteria Peruanos72 Microsoft Excel Programming 5 15th Apr 2009 08:46 PM
delete text in a cell using certian criteria Ken Microsoft Excel Misc 4 12th Apr 2008 06:19 AM
Transfer single cell information to specific cell based on user criteria RoVo Microsoft Excel Programming 0 31st May 2006 04:20 PM
Change the appearance cell where Find criteria is found in a cell =?Utf-8?B?VG9tc3phcg==?= Microsoft Excel Misc 3 30th Dec 2005 02:48 PM
Locate a cell, based on a criteria, then use the 'Cell' command... =?Utf-8?B?Y2Rhdmlkc29u?= Microsoft Excel Misc 1 17th Nov 2005 06:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 PM.