LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Problem with Autofilter macro code

I have a spreadsheet where columns A:P are imported unformatted data.

A macro then adds headings in row 1 of columns R:Z and formulas in cells
R2:Z down to the end of the range in A:P

The result of the formula in column Z is either "" or "Include"

The macro then autofilters on column Z, criteria = "Include" and copies the
resulting data onto a new sheet.

This is the code:

Range("Z1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=9, Criteria1:="Include"

Most of the time this works but because the cells between B1 and P1 are
blank sometimes the Autofilter starts at col R so Field:=9 is right but other
times it seems to start at say column N so the results are wrong.

An option would seem to be to add another instruction in my code to put ""
in cells B1:P1 so all cells between A1 and Z1 are populated but is there a
better/more reliable way please?

Thanks in anticipation
 
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
Autofilter (in a macro) problem BrianR Excel Programming 1 September 18th 06 05:47 PM
macro stops on "selection.autofilter" line of code Rob Excel Programming 5 December 10th 05 02:50 PM
Macro Code Problem unique Excel Programming 3 October 28th 05 04:21 PM
looking for autofilter with code lcoreyl[_16_] Excel Programming 0 September 28th 04 07:49 AM
Application.run Macro Code Problem Todd Huttenstine Excel Programming 1 August 21st 04 08:23 PM


All times are GMT +1. The time now is 06:40 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"