Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Delete rows that are visible after applying filter

Hi

I have the following code:

Selection.AutoFilter Field:=4, Criteria1:="=*ÖVROBL*", Operator:=xlAnd

Now I would like to delete rows that are visible except the first which
contains
the headlines.

How do I write that?
Br
Sverre

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete rows that are visible after applying filter

See
http://www.rondebruin.nl/delete.htm

Try
http://www.rondebruin.nl/delete.htm#AutoFilter


--
Regards Ron de Bruin
http://www.rondebruin.nl



"sverre" wrote in message ...
Hi

I have the following code:

Selection.AutoFilter Field:=4, Criteria1:="=*ÖVROBL*", Operator:=xlAnd

Now I would like to delete rows that are visible except the first which
contains
the headlines.

How do I write that?
Br
Sverre



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Delete rows that are visible after applying filter

Ok, works!

What I dont understand is the following part of the code:

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.delete

Does it tell Excel to move down in the visible area to check wheter the row
is nonempty and if that is the case-delete the row?

Many thanks
Sverker

"Ron de Bruin" skrev:

See
http://www.rondebruin.nl/delete.htm

Try
http://www.rondebruin.nl/delete.htm#AutoFilter


--
Regards Ron de Bruin
http://www.rondebruin.nl



"sverre" wrote in message ...
Hi

I have the following code:

Selection.AutoFilter Field:=4, Criteria1:="=*ÖVROBL*", Operator:=xlAnd

Now I would like to delete rows that are visible except the first which
contains
the headlines.

How do I write that?
Br
Sverre




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete rows that are visible after applying filter

Hi sverre

It will delete all visible cells in rng
rng is the whole ActiveSheet.AutoFilter.Range without the header row

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0



--
Regards Ron de Bruin
http://www.rondebruin.nl



"sverre" wrote in message ...
Ok, works!

What I dont understand is the following part of the code:

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.delete

Does it tell Excel to move down in the visible area to check wheter the row
is nonempty and if that is the case-delete the row?

Many thanks
Sverker

"Ron de Bruin" skrev:

See
http://www.rondebruin.nl/delete.htm

Try
http://www.rondebruin.nl/delete.htm#AutoFilter


--
Regards Ron de Bruin
http://www.rondebruin.nl



"sverre" wrote in message ...
Hi

I have the following code:

Selection.AutoFilter Field:=4, Criteria1:="=*ÖVROBL*", Operator:=xlAnd

Now I would like to delete rows that are visible except the first which
contains
the headlines.

How do I write that?
Br
Sverre






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Delete rows that are visible after applying filter

Hi

So if I would like to modify the column I filter in I just change the range
from A1:A100 to for example D1:100 ?? Or do I need to change any else in the
code?

Best regards
Sverre

"Ron de Bruin" skrev:

Hi sverre

It will delete all visible cells in rng
rng is the whole ActiveSheet.AutoFilter.Range without the header row

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0



--
Regards Ron de Bruin
http://www.rondebruin.nl



"sverre" wrote in message ...
Ok, works!

What I dont understand is the following part of the code:

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.delete

Does it tell Excel to move down in the visible area to check wheter the row
is nonempty and if that is the case-delete the row?

Many thanks
Sverker

"Ron de Bruin" skrev:

See
http://www.rondebruin.nl/delete.htm

Try
http://www.rondebruin.nl/delete.htm#AutoFilter


--
Regards Ron de Bruin
http://www.rondebruin.nl



"sverre" wrote in message ...
Hi

I have the following code:

Selection.AutoFilter Field:=4, Criteria1:="=*ÖVROBL*", Operator:=xlAnd

Now I would like to delete rows that are visible except the first which
contains
the headlines.

How do I write that?
Br
Sverre









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete rows that are visible after applying filter

Only change this line

..Range("A1:A100").AutoFilter Field:=1, Criteria1:=DeleteValue

Note that A1 is the Header cell

So you can use

..Range("D1:D100").AutoFilter Field:=1, Criteria1:=DeleteValue

--
Regards Ron de Bruin
http://www.rondebruin.nl



"sverre" wrote in message ...
Hi

So if I would like to modify the column I filter in I just change the range
from A1:A100 to for example D1:100 ?? Or do I need to change any else in the
code?

Best regards
Sverre

"Ron de Bruin" skrev:

Hi sverre

It will delete all visible cells in rng
rng is the whole ActiveSheet.AutoFilter.Range without the header row

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0



--
Regards Ron de Bruin
http://www.rondebruin.nl



"sverre" wrote in message ...
Ok, works!

What I dont understand is the following part of the code:

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.delete

Does it tell Excel to move down in the visible area to check wheter the row
is nonempty and if that is the case-delete the row?

Many thanks
Sverker

"Ron de Bruin" skrev:

See
http://www.rondebruin.nl/delete.htm

Try
http://www.rondebruin.nl/delete.htm#AutoFilter


--
Regards Ron de Bruin
http://www.rondebruin.nl



"sverre" wrote in message ...
Hi

I have the following code:

Selection.AutoFilter Field:=4, Criteria1:="=*ÖVROBL*", Operator:=xlAnd

Now I would like to delete rows that are visible except the first which
contains
the headlines.

How do I write that?
Br
Sverre









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 only visible rows in filter mode ajezmohd Excel Discussion (Misc queries) 4 September 29th 09 07:04 PM
Help with filter Range & delete rows Les[_8_] Excel Programming 2 October 19th 06 07:33 AM
No. of rows selected from auto filter not visible on toolbar? Asif Akbar Excel Discussion (Misc queries) 2 September 22nd 06 01:05 PM
Applying Formulas to Visible Cells Only SteveC Excel Discussion (Misc queries) 7 June 26th 06 11:44 PM
Applying auto-filter with large number of rows Hari Excel Discussion (Misc queries) 3 January 30th 06 03:06 AM


All times are GMT +1. The time now is 05:35 AM.

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

About Us

"It's about Microsoft Excel"