Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JHL JHL is offline
external usenet poster
 
Posts: 56
Default Deleting rows with Advance Filter in recorded Macro

Im using Excel 97. Im not a programmer. Using the macro recorder to learn
coding. Im working on a situation where Im selecting data using the
AutoFilter. Once the criteria is made, I want to delete the rows selected.
The recorder lists it as:

Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="=DCNSU", Operator:=xlOr, _
Criteria2:="=DUPCTRL"
ActiveCell.Offset(1, 0).Rows("1:65000").EntireRow.Select
Selection.Delete Shift:=xlUp


I changed the rows selection to read €œ1:65000€€¦ because I dont anticipate
the selection ever being larger than 65000 rows. However I cant be exactly
sure, and I would perfer it to reflect variable changing rows? Can someone
tell me how to re-code this?

Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleting rows with Advance Filter in recorded Macro


Rows(Activecell.Row + 1 & ":" & Rows.count).EntireRow.Select



--
Regards,
Tom Ogilvy



"JHL" wrote in message
...
I'm using Excel 97. I'm not a programmer. Using the macro recorder to

learn
coding. I'm working on a situation where I'm selecting data using the
AutoFilter. Once the criteria is made, I want to delete the rows

selected.
The recorder lists it as:

Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="=DCNSU", Operator:=xlOr, _
Criteria2:="=DUPCTRL"
ActiveCell.Offset(1, 0).Rows("1:65000").EntireRow.Select
Selection.Delete Shift:=xlUp


I changed the rows selection to read "1:65000". because I don't

anticipate
the selection ever being larger than 65000 rows. However I can't be

exactly
sure, and I would perfer it to reflect variable changing rows? Can

someone
tell me how to re-code this?

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
JHL JHL is offline
external usenet poster
 
Posts: 56
Default Deleting rows with Advance Filter in recorded Macro

Thank You this worked perfectly!

"Tom Ogilvy" wrote:


Rows(Activecell.Row + 1 & ":" & Rows.count).EntireRow.Select



--
Regards,
Tom Ogilvy



"JHL" wrote in message
...
I'm using Excel 97. I'm not a programmer. Using the macro recorder to

learn
coding. I'm working on a situation where I'm selecting data using the
AutoFilter. Once the criteria is made, I want to delete the rows

selected.
The recorder lists it as:

Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=4, Criteria1:="=DCNSU", Operator:=xlOr, _
Criteria2:="=DUPCTRL"
ActiveCell.Offset(1, 0).Rows("1:65000").EntireRow.Select
Selection.Delete Shift:=xlUp


I changed the rows selection to read "1:65000". because I don't

anticipate
the selection ever being larger than 65000 rows. However I can't be

exactly
sure, and I would perfer it to reflect variable changing rows? Can

someone
tell me how to re-code this?

Thanks in advance.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Deleting rows with Advance Filter in recorded Macro

I would try something like this:
Looping through values in Column A and deleting the rows for cells
containg your criteria.
This would be quite slow for 65,000 lines though.
There may be a better way.
And I'm not sure if there are any flaws in my code.



Sub DeleteEntries()

Range("A1").Select
Do Until IsEmpty(ActiveCell)
If ActiveCell.Value = "DCNSU" Or ActiveCell.Value = "DUPCTRL" Then
ActiveCell.EntireRow.Select
Selection.Delete Shift:=xlUp
End If
ActiveCell.Offset(1, 0).Select
Loop

End Sub


Somethinglikeant

  #5   Report Post  
Posted to microsoft.public.excel.programming
JHL JHL is offline
external usenet poster
 
Posts: 56
Default Deleting rows with Advance Filter in recorded Macro

Thank you, I had a loop performing this, but thought the autofilter would be
faster, and it is.

" wrote:

I would try something like this:
Looping through values in Column A and deleting the rows for cells
containg your criteria.
This would be quite slow for 65,000 lines though.
There may be a better way.
And I'm not sure if there are any flaws in my code.



Sub DeleteEntries()

Range("A1").Select
Do Until IsEmpty(ActiveCell)
If ActiveCell.Value = "DCNSU" Or ActiveCell.Value = "DUPCTRL" Then
ActiveCell.EntireRow.Select
Selection.Delete Shift:=xlUp
End If
ActiveCell.Offset(1, 0).Select
Loop

End Sub


Somethinglikeant




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
Data filter and deleting rows in visual basic Ruben Excel Discussion (Misc queries) 0 August 24th 08 08:38 PM
advance filter sustitution in a macro - shared workbook Belinda7237 Excel Worksheet Functions 0 June 11th 08 01:52 AM
Deleting rows in filter mode - Excel 2007 Michael New Users to Excel 0 April 17th 08 10:56 PM
Advance filter search does not filter an exact match cfiiland Excel Programming 1 June 10th 05 12:44 PM
Deleting rows which match filter Fred Smith Excel Programming 2 February 13th 04 02:24 AM


All times are GMT +1. The time now is 11:28 PM.

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"