Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following autofilter statement in my macro:
Selection.AutoFilter Field:=1, Criteria1:="=*SKU*", Operator:=xlAnd The term "SKU" in this statment is Dimensioned as a string variable but it is being used literally. That is the autofilter is selecting lines that contain SKU. How do I get this autofilter statement to understand SKU is a string variable? Thank you. John Keith |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you need SKU dimensioned as a string variable someplace else? If so, I
think I'd change it so that it's mySKU or something like that so that you know it's the variable. -- HTH, Barb Reinhardt "John Keith" wrote: I have the following autofilter statement in my macro: Selection.AutoFilter Field:=1, Criteria1:="=*SKU*", Operator:=xlAnd The term "SKU" in this statment is Dimensioned as a string variable but it is being used literally. That is the autofilter is selecting lines that contain SKU. How do I get this autofilter statement to understand SKU is a string variable? Thank you. John Keith |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 14 Sep 2008 06:07:01 -0700, Barb Reinhardt
wrote: Do you need SKU dimensioned as a string variable someplace else? If so, I think I'd change it so that it's mySKU or something like that so that you know it's the variable. Barb, Wow! What a quick response. I do use the variable one other time, but I can eaily change the name. But changing the variable name does not solve the problem, the autofilter now thinks it is searching for mySKU. John Keith |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This works with me:
Selection.AutoFilter Field:=1, Criteria1:=SKU, Operator:=xlAnd RBS "John Keith" wrote in message ... I have the following autofilter statement in my macro: Selection.AutoFilter Field:=1, Criteria1:="=*SKU*", Operator:=xlAnd The term "SKU" in this statment is Dimensioned as a string variable but it is being used literally. That is the autofilter is selecting lines that contain SKU. How do I get this autofilter statement to understand SKU is a string variable? Thank you. John Keith |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In this line, you are searching for somethng that contains SKU. Don't
change this one. Selection.AutoFilter Field:=1, Criteria1:="=*SKU*", Operator:=xlAnd If you refer to SKU someplace else, use mySKU or something so that it knows they are different. -- HTH, Barb Reinhardt "RB Smissaert" wrote: This works with me: Selection.AutoFilter Field:=1, Criteria1:=SKU, Operator:=xlAnd RBS "John Keith" wrote in message ... I have the following autofilter statement in my macro: Selection.AutoFilter Field:=1, Criteria1:="=*SKU*", Operator:=xlAnd The term "SKU" in this statment is Dimensioned as a string variable but it is being used literally. That is the autofilter is selecting lines that contain SKU. How do I get this autofilter statement to understand SKU is a string variable? Thank you. John Keith |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 14 Sep 2008 11:51:01 -0700, Barb Reinhardt
wrote: In this line, you are searching for somethng that contains SKU. Don't change this one. Selection.AutoFilter Field:=1, Criteria1:="=*SKU*", Operator:=xlAnd If you refer to SKU someplace else, use mySKU or something so that it knows they are different. Barb, Thanks for following up, but the above command is still interpreting "SKU" as the item I am trying to filter on rather than the value of 'SKU". (This line is at the end of my macro right now, and when I go to check the filter settings it says it was looking for rows that contains "SKU" in the first column. But I'm confused about something else. The string "SKU" never appears in the column I am filtering but all of my original rows still are visible, so it's as if no filtering was done. I'm still confused. John Keith |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 14 Sep 2008 14:10:32 +0100, "RB Smissaert"
wrote: This works with me: Selection.AutoFilter Field:=1, Criteria1:=SKU, Operator:=xlAnd In this case the filter does recognize "SKU" as a variable but this criteria is for if the cell equals the value of SKU. I need the criteria to be contains the value of "SKU". That is why my first post had the asterisk on either side of "SKU". Any one else have a suggestion? John Keith |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ah, yes, didn't read it properly.
RBS "John Keith" wrote in message ... On Sun, 14 Sep 2008 14:10:32 +0100, "RB Smissaert" wrote: This works with me: Selection.AutoFilter Field:=1, Criteria1:=SKU, Operator:=xlAnd In this case the filter does recognize "SKU" as a variable but this criteria is for if the cell equals the value of SKU. I need the criteria to be contains the value of "SKU". That is why my first post had the asterisk on either side of "SKU". Any one else have a suggestion? John Keith |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Now that I think about this, I'm wondering if you are trying to find cells
that are equal to whatever is in your variable SKU. Can you clarify what you want. Barb Reinhardt "John Keith" wrote: I have the following autofilter statement in my macro: Selection.AutoFilter Field:=1, Criteria1:="=*SKU*", Operator:=xlAnd The term "SKU" in this statment is Dimensioned as a string variable but it is being used literally. That is the autofilter is selecting lines that contain SKU. How do I get this autofilter statement to understand SKU is a string variable? Thank you. John Keith |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 14 Sep 2008 12:02:01 -0700, Barb Reinhardt
wrote: Now that I think about this, I'm wondering if you are trying to find cells that are equal to whatever is in your variable SKU. Can you clarify what you want. Barb, Yes, I am trying to find rows that contain the value of the variable SKU. John Keith |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try Criteria1:="=*" & SKU & "*",
-- Gary "John Keith" wrote in message ... On Sun, 14 Sep 2008 12:02:01 -0700, Barb Reinhardt wrote: Now that I think about this, I'm wondering if you are trying to find cells that are equal to whatever is in your variable SKU. Can you clarify what you want. Barb, Yes, I am trying to find rows that contain the value of the variable SKU. John Keith |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 14 Sep 2008 15:31:45 -0400, "Gary Keramidas"
<GKeramidasATmsn.com wrote: try Criteria1:="=*" & SKU & "*", Gary, The autofilter settings now reflect the contents of the string variable so that is a big step forward. (Thanks, how does one figure out the correct syntax for somethig like this????) But...... as noted in in another reply from me the filter does not appear to be working as all the original rows still appear. I'll go experiment so more but if anyone else has a suggestion I'm all ears. John Keith |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Recording a macro showed me the right syntax:
Sub test() Dim str As String str = "g" Selection.AutoFilter Field:=1, Criteria1:="=**" & str & "**" End Sub RBS "John Keith" wrote in message ... On Sun, 14 Sep 2008 15:31:45 -0400, "Gary Keramidas" <GKeramidasATmsn.com wrote: try Criteria1:="=*" & SKU & "*", Gary, The autofilter settings now reflect the contents of the string variable so that is a big step forward. (Thanks, how does one figure out the correct syntax for somethig like this????) But...... as noted in in another reply from me the filter does not appear to be working as all the original rows still appear. I'll go experiment so more but if anyone else has a suggestion I'm all ears. John Keith |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 14 Sep 2008 14:12:50 -0600, John Keith wrote:
But...... as noted in in another reply from me the filter does not appear to be working as all the original rows still appear. I'll go experiment so more but if anyone else has a suggestion I'm all ears. The filter is not working even when I manually go through the process so something else is clearly going on. Thanks for all the suggestions. John Keith |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Trying To Append String Variable To Another String Variable | Excel Programming | |||
Im literally a beginner, please help! | Excel Programming | |||
setting a range variable equal to the value of a string variable | Excel Programming | |||
Literally - every other time | Excel Programming | |||
How do I convert an integer variable to a string variable? | Excel Programming |