Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Delete Rows on Set Criteria

Hi All

An easy one for all you experts

I need a macro to delete the all the rows on the active sheet if in Column F
/ Row5 the values in all the cells in Column F do not match the value in
Column F / Row5
--
Many Thanks

Sue
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Delete Rows on Set Criteria

Sue,

That doesn't make sense, what are we comparing Column F to

Mike

"Sue" wrote:

Hi All

An easy one for all you experts

I need a macro to delete the all the rows on the active sheet if in Column F
/ Row5 the values in all the cells in Column F do not match the value in
Column F / Row5
--
Many Thanks

Sue

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Delete Rows on Set Criteria

All the cells in Row F? Do you mean all 256 in Excel 2003 and who knows
how many in 2007? Or are you just talking about the cells in the UsedRange?

Barb Reinhardt

"Sue" wrote:

Hi All

An easy one for all you experts

I need a macro to delete the all the rows on the active sheet if in Column F
/ Row5 the values in all the cells in Column F do not match the value in
Column F / Row5
--
Many Thanks

Sue

  #4   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Delete Rows on Set Criteria

Hi

My mistake

I should have stipulated the used range

and in Column F / Row 5 there is a number and if any cell in the used range
in Column F does not match that number then the row is deleted
--
Many Thanks

Sue


"Barb Reinhardt" wrote:

All the cells in Row F? Do you mean all 256 in Excel 2003 and who knows
how many in 2007? Or are you just talking about the cells in the UsedRange?

Barb Reinhardt

"Sue" wrote:

Hi All

An easy one for all you experts

I need a macro to delete the all the rows on the active sheet if in Column F
/ Row5 the values in all the cells in Column F do not match the value in
Column F / Row5
--
Many Thanks

Sue

  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Delete Rows on Set Criteria

Maybe

Sub copyit()
Dim MyRange, MyRange1 As Range, DeleteRange As Range
myvalue = Range("F5").Value
lastrow = Cells(Rows.Count, "F").End(xlUp).Row
Set MyRange = Range("F6:F" & lastrow)
For Each c In MyRange
If c.Value < myvalue Then
If DeleteRange Is Nothing Then
Set DeleteRange = c.EntireRow
Else
Set DeleteRange = Union(DeleteRange, c.EntireRow)
End If

End If
Next
If Not DeleteRange Is Nothing Then
DeleteRange.Delete
End If
End Sub

Mike

"Sue" wrote:

Hi

My mistake

I should have stipulated the used range

and in Column F / Row 5 there is a number and if any cell in the used range
in Column F does not match that number then the row is deleted
--
Many Thanks

Sue


"Barb Reinhardt" wrote:

All the cells in Row F? Do you mean all 256 in Excel 2003 and who knows
how many in 2007? Or are you just talking about the cells in the UsedRange?

Barb Reinhardt

"Sue" wrote:

Hi All

An easy one for all you experts

I need a macro to delete the all the rows on the active sheet if in Column F
/ Row5 the values in all the cells in Column F do not match the value in
Column F / Row5
--
Many Thanks

Sue

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Delete Rows on Set Criteria

Hi Sue, I think this is what you are looking for.

Sub delRws()
Dim lstRw As Long, i As Long
lstRw = ActiveSheet.Cells(Rows.Count, 6).End(xlUp).Row
For i = lstRow To 6 Step - 1
If ActiveSheet.Cells(i, 6) < ActiveSheet.Range("F5") Then
ActiveSheet.Cells(i, 6).EntireRow.Delete
End If
Next
End Sub

"Sue" wrote:

Hi All

An easy one for all you experts

I need a macro to delete the all the rows on the active sheet if in Column F
/ Row5 the values in all the cells in Column F do not match the value in
Column F / Row5
--
Many Thanks

Sue

  #9   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Delete Rows on Set Criteria

Hi Everybody

Who replied thanks for your help

Eventually used JLGWhiz's solution after I found the typo error


--
Many Thanks

Sue


"JLGWhiz" wrote:

Hi Sue, I think this is what you are looking for.

Sub delRws()
Dim lstRw As Long, i As Long
lstRw = ActiveSheet.Cells(Rows.Count, 6).End(xlUp).Row
For i = lstRow To 6 Step - 1
If ActiveSheet.Cells(i, 6) < ActiveSheet.Range("F5") Then
ActiveSheet.Cells(i, 6).EntireRow.Delete
End If
Next
End Sub

"Sue" wrote:

Hi All

An easy one for all you experts

I need a macro to delete the all the rows on the active sheet if in Column F
/ Row5 the values in all the cells in Column F do not match the value in
Column F / Row5
--
Many Thanks

Sue

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 Rows that fit a certain criteria jpittari Excel Programming 3 November 2nd 07 03:22 PM
Delete rows that do not match criteria rlee1999 Excel Programming 1 November 3rd 06 03:16 PM
Delete rows with different criteria John Excel Programming 7 July 13th 05 05:38 PM
delete rows with criteria S.E. Excel Programming 5 September 9th 04 04:04 PM
Delete rows w/o criteria RickK[_2_] Excel Programming 2 October 31st 03 04:48 PM


All times are GMT +1. The time now is 01:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"