Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Adv Filter Formula Criteria

I'm trying to access the Advanced Filter Programmatically. I have a crude
macro that runs to completion but falters on:

y.Range("C2").Formula = "=" & "OR(Source!J2<" & """""" _
& "," & "AND" & "(Source!K2<" & """""" _
& ",Source!K2<" & "" & """Consumer""" & "))" & ""

This is what ends up in the cell:
=OR(Source!#REF!<"",AND(Source!#REF!<"",Source!# REF!<"Consumer"))

It should be:
=OR(Source!J7<"",AND(Source!K7<"",Source!K7<"Co nsumer"))

How can I rewrite this so it will create a working formula in the cell? I
know criteria work because I can run the Advanced Filter successfully if I do
it manually.

--
tj
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Adv Filter Formula Criteria

Your code worked ok for me.

Are you sure that the #ref's showed that way?

Have you checked to verify that there is a worksheet named Source in that
workbook?

And your line of code looks like it could be just:

y.Range("C2").Formula _
= "=OR(Source!J2<"""",AND(Source!K2<"""",Source!K2 <""Consumer""))"



tjtjjtjt wrote:

I'm trying to access the Advanced Filter Programmatically. I have a crude
macro that runs to completion but falters on:

y.Range("C2").Formula = "=" & "OR(Source!J2<" & """""" _
& "," & "AND" & "(Source!K2<" & """""" _
& ",Source!K2<" & "" & """Consumer""" & "))" & ""

This is what ends up in the cell:
=OR(Source!#REF!<"",AND(Source!#REF!<"",Source!# REF!<"Consumer"))

It should be:
=OR(Source!J7<"",AND(Source!K7<"",Source!K7<"Co nsumer"))

How can I rewrite this so it will create a working formula in the cell? I
know criteria work because I can run the Advanced Filter successfully if I do
it manually.

--
tj


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Adv Filter Formula Criteria

The macro renames Sheet1 to Source earlier on. The code executes, but when I
look at the Formula in worksheet, it comes up #REF, and there are no filter
results on Results.

Running the same Filter typed manually, it works.

I'll try the simpler line you provided below and post back with results.


--
tj


"Dave Peterson" wrote:

Your code worked ok for me.

Are you sure that the #ref's showed that way?

Have you checked to verify that there is a worksheet named Source in that
workbook?

And your line of code looks like it could be just:

y.Range("C2").Formula _
= "=OR(Source!J2<"""",AND(Source!K2<"""",Source!K2 <""Consumer""))"



tjtjjtjt wrote:

I'm trying to access the Advanced Filter Programmatically. I have a crude
macro that runs to completion but falters on:

y.Range("C2").Formula = "=" & "OR(Source!J2<" & """""" _
& "," & "AND" & "(Source!K2<" & """""" _
& ",Source!K2<" & "" & """Consumer""" & "))" & ""

This is what ends up in the cell:
=OR(Source!#REF!<"",AND(Source!#REF!<"",Source!# REF!<"Consumer"))

It should be:
=OR(Source!J7<"",AND(Source!K7<"",Source!K7<"Co nsumer"))

How can I rewrite this so it will create a working formula in the cell? I
know criteria work because I can run the Advanced Filter successfully if I do
it manually.

--
tj


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Adv Filter Formula Criteria

I'm still getting the #REF error. I'll play with it a while and post back
tomorrow.

--
tj


"Dave Peterson" wrote:

Your code worked ok for me.

Are you sure that the #ref's showed that way?

Have you checked to verify that there is a worksheet named Source in that
workbook?

And your line of code looks like it could be just:

y.Range("C2").Formula _
= "=OR(Source!J2<"""",AND(Source!K2<"""",Source!K2 <""Consumer""))"



tjtjjtjt wrote:

I'm trying to access the Advanced Filter Programmatically. I have a crude
macro that runs to completion but falters on:

y.Range("C2").Formula = "=" & "OR(Source!J2<" & """""" _
& "," & "AND" & "(Source!K2<" & """""" _
& ",Source!K2<" & "" & """Consumer""" & "))" & ""

This is what ends up in the cell:
=OR(Source!#REF!<"",AND(Source!#REF!<"",Source!# REF!<"Consumer"))

It should be:
=OR(Source!J7<"",AND(Source!K7<"",Source!K7<"Co nsumer"))

How can I rewrite this so it will create a working formula in the cell? I
know criteria work because I can run the Advanced Filter successfully if I do
it manually.

--
tj


--

Dave Peterson

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
formula to find the filter criteria [email protected] Excel Worksheet Functions 12 December 30th 05 07:04 PM
Advanced Filter criteria (formula) Gareth Excel Worksheet Functions 3 December 20th 05 09:12 PM
Filter criteria Tony Excel Discussion (Misc queries) 2 November 24th 05 10:40 AM
"Criteria Range" in the "Data/Filter/Advanced Filter" to select Du TC Excel Worksheet Functions 1 May 12th 05 02:06 AM
Filter Criteria desmondleow[_7_] Excel Programming 1 December 16th 03 01:10 PM


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