Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Manual Autofilter works, but recorded Macro does something else

Still failing to move from newbie status and my kitchen table, I have a
question on autofilter:

I am using Excel 2003 and I am trying to Autofilter a table. I wrote the
code manually and did not get it to work. Then I did the operation manually
and recorded a macro without problem, but when I run the macro, no data is
visible.

I want all rows that have "SANT" in column 5 and "User Needs Document" in
column 18 to show which in this case is eight (when I do it manually).

This is the recorded macro code:

Range("H4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="SANT"
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6

' some more of the same to get to the right hand column

ActiveWindow.ScrollColumn = 15
Selection.AutoFilter Field:=18, Criteria1:="User Needs Document"
End Sub

When recording, this results in 8 data posts, when running the macro with
exactly the same conditions (as far as I can tell), the autofilter does not
return any visible rows. What am I (or Excel :-) doing wrong?

Help is greatly appreciated!

Peter S


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Manual Autofilter works, but recorded Macro does something else

Sub BBB()
With Range("A1:T50")
.AutoFilter Field:=5, _
Criteria1:="SANT"
.AutoFilter Field:=18, _
Criteria1:="User Needs Document"
End With
End Sub

worked fine for me. Change A1:T50 to reflect your data range.

--
Regards,
Tom Ogilvy


"Peters" wrote:

Still failing to move from newbie status and my kitchen table, I have a
question on autofilter:

I am using Excel 2003 and I am trying to Autofilter a table. I wrote the
code manually and did not get it to work. Then I did the operation manually
and recorded a macro without problem, but when I run the macro, no data is
visible.

I want all rows that have "SANT" in column 5 and "User Needs Document" in
column 18 to show which in this case is eight (when I do it manually).

This is the recorded macro code:

Range("H4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="SANT"
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6

' some more of the same to get to the right hand column

ActiveWindow.ScrollColumn = 15
Selection.AutoFilter Field:=18, Criteria1:="User Needs Document"
End Sub

When recording, this results in 8 data posts, when running the macro with
exactly the same conditions (as far as I can tell), the autofilter does not
return any visible rows. What am I (or Excel :-) doing wrong?

Help is greatly appreciated!

Peter S


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Manual Autofilter works, but recorded Macro does something els

Finally, success!

Maybe I should have told you that I am running a swedish version of Excel
and that "SANT" means "TRUE" in english. When I replace "SANT" with "S", both
your's and my code work. I thought about this earlier and checked that the
cells format were ordinary text and not boolean, but I must say that Excel
acted strange, because when i wrote "TRUE" in my code, "SANT" appeared in the
spreadsheet.

Well, problem solved. And by the way, my english Office version is waiting
at the post office. I will get it tomorrow!

Thanks for the inspiration Tom. I think that the ten or so lines of code
before this strange autofilter comes from you originally also! I owe you!

Peter



--
--------
Peter Sebelius


"Tom Ogilvy" wrote:

Sub BBB()
With Range("A1:T50")
.AutoFilter Field:=5, _
Criteria1:="SANT"
.AutoFilter Field:=18, _
Criteria1:="User Needs Document"
End With
End Sub

worked fine for me. Change A1:T50 to reflect your data range.

--
Regards,
Tom Ogilvy


"Peters" wrote:

Still failing to move from newbie status and my kitchen table, I have a
question on autofilter:

I am using Excel 2003 and I am trying to Autofilter a table. I wrote the
code manually and did not get it to work. Then I did the operation manually
and recorded a macro without problem, but when I run the macro, no data is
visible.

I want all rows that have "SANT" in column 5 and "User Needs Document" in
column 18 to show which in this case is eight (when I do it manually).

This is the recorded macro code:

Range("H4").Select
Selection.AutoFilter
Selection.AutoFilter Field:=5, Criteria1:="SANT"
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 6

' some more of the same to get to the right hand column

ActiveWindow.ScrollColumn = 15
Selection.AutoFilter Field:=18, Criteria1:="User Needs Document"
End Sub

When recording, this results in 8 data posts, when running the macro with
exactly the same conditions (as far as I can tell), the autofilter does not
return any visible rows. What am I (or Excel :-) doing wrong?

Help is greatly appreciated!

Peter S


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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
autofilter problem in Mac, but works in Windows, Excel 2003 Curran Excel Discussion (Misc queries) 1 March 11th 09 01:10 PM
Manual AutoFilter - Vlookup, Index, Match, Array??? TEAM Excel Worksheet Functions 4 May 16th 06 02:49 AM
RECORDED MACRO PASTE'S DATE DIFFERENTLY TO MANUAL PASTE Pauldecan Excel Worksheet Functions 0 June 23rd 05 05:45 PM
Autofilter works... just not in my ListBox_click! Mike Excel Programming 2 January 12th 05 01:55 PM


All times are GMT +1. The time now is 08:04 PM.

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"