PC Review


Reply
Thread Tools Rate Thread

Delete rows that are visible after applying filter

 
 
=?Utf-8?B?c3ZlcnJl?=
Guest
Posts: n/a
 
      30th Oct 2006
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 With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      30th Oct 2006
See
http://www.rondebruin.nl/delete.htm

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


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



"sverre" <(E-Mail Removed)> wrote in message news:E7D5E2F0-A393-4E73-81A1-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?c3ZlcnJl?=
Guest
Posts: n/a
 
      31st Oct 2006
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" <(E-Mail Removed)> wrote in message news:E7D5E2F0-A393-4E73-81A1-(E-Mail Removed)...
> > 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 With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      31st Oct 2006
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" <(E-Mail Removed)> wrote in message news:E36814D8-5DD2-46B3-AE78-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message news:E7D5E2F0-A393-4E73-81A1-(E-Mail Removed)...
>> > 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 With Quote
 
=?Utf-8?B?c3ZlcnJl?=
Guest
Posts: n/a
 
      1st Nov 2006
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" <(E-Mail Removed)> wrote in message news:E36814D8-5DD2-46B3-AE78-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message news:E7D5E2F0-A393-4E73-81A1-(E-Mail Removed)...
> >> > 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 With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      1st Nov 2006
Only change this line

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

Note that A1 is the Header cell

So you can use

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

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



"sverre" <(E-Mail Removed)> wrote in message news:B179CA57-F351-4CD7-8314-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message news:E36814D8-5DD2-46B3-AE78-(E-Mail Removed)...
>> > 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" <(E-Mail Removed)> wrote in message news:E7D5E2F0-A393-4E73-81A1-(E-Mail Removed)...
>> >> > 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 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
Visible row index after applying a filter in Excel Hasmet Akgun Microsoft Excel Discussion 1 23rd Jan 2010 06:28 AM
delete only visible rows in filter mode ajezmohd Microsoft Excel Misc 4 29th Sep 2009 07:04 PM
Coding for a delete query when applying a filter =?Utf-8?B?R3JhZW1l?= Microsoft Access Form Coding 1 19th Mar 2007 06:12 PM
Applying auto-filter with large number of rows Hari Microsoft Excel Misc 3 30th Jan 2006 03:06 AM
Counting only visible rows and not using a filter Carl Olsson Microsoft Excel Worksheet Functions 2 26th Feb 2004 08:24 PM


Features
 

Advertising
 

Newsgroups
 


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