Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VB Question - AutoFilter related - 'Criteria1:' secion of my code

Hi,

I have a simple bit of code to take me to another worksheet and
automatically select specific information falling under a autofilter.
Sample below:

Sheets("Sheet2").Select
Selection.AutoFilter Field:=1, Criteria1:="RandomText"
Range("A1").Select

This works great but it would be even better if I could refer to a
cell within the spreadsheet. How do I go about changing the criteria
to be a cell reference?

Since I have multiple sheets, do I need to specify the sheet name that
I'm calling the cell reference from?


Many, many thanks if you can help with this.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VB Question - AutoFilter related - 'Criteria1:' secion of my code

Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value

may work ok.

Midnight wrote:

Hi,

I have a simple bit of code to take me to another worksheet and
automatically select specific information falling under a autofilter.
Sample below:

Sheets("Sheet2").Select
Selection.AutoFilter Field:=1, Criteria1:="RandomText"
Range("A1").Select

This works great but it would be even better if I could refer to a
cell within the spreadsheet. How do I go about changing the criteria
to be a cell reference?

Since I have multiple sheets, do I need to specify the sheet name that
I'm calling the cell reference from?

Many, many thanks if you can help with this.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VB Question - AutoFilter related - 'Criteria1:' secion of my code

That works. Thanks Dave. Now there is one other thing that is not
essential, but will improve things even further. Is there a way of
looking at two cell ranges in the criteria instead of just the one.

To put it another way, in the same way you can go =E8&" "&F8 in a cell
- is something like that possible for the purpose of criteria in the
VB code?

I have no idea how this would be written - whether it would mean
putting in a AND command (if there is such a thing) or if it could be
included somehow in the range section.

Thanks.


On 8 Aug, 15:56, Dave Peterson wrote:
Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value

may work ok.





Midnight wrote:

Hi,


I have a simple bit of code to take me to another worksheet and
automatically select specific information falling under a autofilter.
Sample below:


Sheets("Sheet2").Select
Selection.AutoFilter Field:=1, Criteria1:="RandomText"
Range("A1").Select


This works great but it would be even better if I could refer to a
cell within the spreadsheet. How do I go about changing the criteria
to be a cell reference?


Since I have multiple sheets, do I need to specify the sheet name that
I'm calling the cell reference from?


Many, many thanks if you can help with this.


--

Dave Peterson- Hide quoted text -

- Show quoted text -



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VB Question - AutoFilter related - 'Criteria1:' secion of my code

Just concatenate your strings (I think):

Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value & " " _
worksheets("adifferent").range("x999").value




Midnight wrote:

That works. Thanks Dave. Now there is one other thing that is not
essential, but will improve things even further. Is there a way of
looking at two cell ranges in the criteria instead of just the one.

To put it another way, in the same way you can go =E8&" "&F8 in a cell
- is something like that possible for the purpose of criteria in the
VB code?

I have no idea how this would be written - whether it would mean
putting in a AND command (if there is such a thing) or if it could be
included somehow in the range section.

Thanks.

On 8 Aug, 15:56, Dave Peterson wrote:
Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value

may work ok.





Midnight wrote:

Hi,


I have a simple bit of code to take me to another worksheet and
automatically select specific information falling under a autofilter.
Sample below:


Sheets("Sheet2").Select
Selection.AutoFilter Field:=1, Criteria1:="RandomText"
Range("A1").Select


This works great but it would be even better if I could refer to a
cell within the spreadsheet. How do I go about changing the criteria
to be a cell reference?


Since I have multiple sheets, do I need to specify the sheet name that
I'm calling the cell reference from?


Many, many thanks if you can help with this.


--

Dave Peterson- Hide quoted text -

- Show quoted text -


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VB Question - AutoFilter related - 'Criteria1:' secion of my code

Hi Dave,

The code worked good but I had to take out the " " _ - I can see
why you put that in, and it's exactly what I need (to have a space
between the two values) but VB didn't allow it. Is there another way
you can think of doing it? I tried taking out the underscore but no
joy.

As a workaround, I can add a space to the end of the text string of
the first cell value (at the source), but it would be better if I
could incorporate the space into the code.

Jon.


On 8 Aug, 18:23, Dave Peterson wrote:
Just concatenate your strings (I think):

Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value & " " _
worksheets("adifferent").range("x999").value





Midnight wrote:

That works. Thanks Dave. Now there is one other thing that is not
essential, but will improve things even further. Is there a way of
looking at two cell ranges in the criteria instead of just the one.


To put it another way, in the same way you can go =E8&" "&F8 in a cell
- is something like that possible for the purpose of criteria in the
VB code?


I have no idea how this would be written - whether it would mean
putting in a AND command (if there is such a thing) or if it could be
included somehow in the range section.


Thanks.


On 8 Aug, 15:56, Dave Peterson wrote:
Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value


may work ok.


Midnight wrote:


Hi,


I have a simple bit of code to take me to another worksheet and
automatically select specific information falling under a autofilter.
Sample below:


Sheets("Sheet2").Select
Selection.AutoFilter Field:=1, Criteria1:="RandomText"
Range("A1").Select


This works great but it would be even better if I could refer to a
cell within the spreadsheet. How do I go about changing the criteria
to be a cell reference?


Since I have multiple sheets, do I need to specify the sheet name that
I'm calling the cell reference from?


Many, many thanks if you can help with this.


--


Dave Peterson- Hide quoted text -


- Show quoted text -


--

Dave Peterson- Hide quoted text -

- Show quoted text -





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VB Question - AutoFilter related - 'Criteria1:' secion of my code

I omitted an ampersand.

Criteria1:=worksheets("othersheet").range("a177"). value & " " _
& worksheets("adifferent").range("x999").value

Sorry.

Midnight wrote:

Hi Dave,

The code worked good but I had to take out the " " _ - I can see
why you put that in, and it's exactly what I need (to have a space
between the two values) but VB didn't allow it. Is there another way
you can think of doing it? I tried taking out the underscore but no
joy.

As a workaround, I can add a space to the end of the text string of
the first cell value (at the source), but it would be better if I
could incorporate the space into the code.

Jon.

On 8 Aug, 18:23, Dave Peterson wrote:
Just concatenate your strings (I think):

Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value & " " _
worksheets("adifferent").range("x999").value





Midnight wrote:

That works. Thanks Dave. Now there is one other thing that is not
essential, but will improve things even further. Is there a way of
looking at two cell ranges in the criteria instead of just the one.


To put it another way, in the same way you can go =E8&" "&F8 in a cell
- is something like that possible for the purpose of criteria in the
VB code?


I have no idea how this would be written - whether it would mean
putting in a AND command (if there is such a thing) or if it could be
included somehow in the range section.


Thanks.


On 8 Aug, 15:56, Dave Peterson wrote:
Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value


may work ok.


Midnight wrote:


Hi,


I have a simple bit of code to take me to another worksheet and
automatically select specific information falling under a autofilter.
Sample below:


Sheets("Sheet2").Select
Selection.AutoFilter Field:=1, Criteria1:="RandomText"
Range("A1").Select


This works great but it would be even better if I could refer to a
cell within the spreadsheet. How do I go about changing the criteria
to be a cell reference?


Since I have multiple sheets, do I need to specify the sheet name that
I'm calling the cell reference from?


Many, many thanks if you can help with this.


--


Dave Peterson- Hide quoted text -


- Show quoted text -


--

Dave Peterson- Hide quoted text -

- Show quoted text -


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VB Question - AutoFilter related - 'Criteria1:' secion of my code

On 9 Aug, 13:10, Dave Peterson wrote:
I omitted an ampersand.

Criteria1:=worksheets("othersheet").range("a177"). value & " " _
& worksheets("adifferent").range("x999").value

Sorry.





Midnight wrote:

Hi Dave,


The code worked good but I had to take out the " " _ - I can see
why you put that in, and it's exactly what I need (to have a space
between the two values) but VB didn't allow it. Is there another way
you can think of doing it? I tried taking out the underscore but no
joy.


As a workaround, I can add a space to the end of the text string of
the first cell value (at the source), but it would be better if I
could incorporate the space into the code.


Jon.


On 8 Aug, 18:23, Dave Peterson wrote:
Just concatenate your strings (I think):


Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value & " " _
worksheets("adifferent").range("x999").value


Midnight wrote:


That works. Thanks Dave. Now there is one other thing that is not
essential, but will improve things even further. Is there a way of
looking at two cell ranges in the criteria instead of just the one.


To put it another way, in the same way you can go =E8&" "&F8 in a cell
- is something like that possible for the purpose of criteria in the
VB code?


I have no idea how this would be written - whether it would mean
putting in a AND command (if there is such a thing) or if it could be
included somehow in the range section.


Thanks.


On 8 Aug, 15:56, Dave Peterson wrote:
Selection.AutoFilter Field:=1, _
Criteria1:=worksheets("othersheet").range("a177"). value


may work ok.


Midnight wrote:


Hi,


I have a simple bit of code to take me to another worksheet and
automatically select specific information falling under a autofilter.
Sample below:


Sheets("Sheet2").Select
Selection.AutoFilter Field:=1, Criteria1:="RandomText"
Range("A1").Select


This works great but it would be even better if I could refer to a
cell within the spreadsheet. How do I go about changing the criteria
to be a cell reference?


Since I have multiple sheets, do I need to specify the sheet name that
I'm calling the cell reference from?


Many, many thanks if you can help with this.


--


Dave Peterson- Hide quoted text -


- Show quoted text -


--


Dave Peterson- Hide quoted text -


- Show quoted text -


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Thanks for your help Dave. It now works just as I wanted.

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
Autofilter - formatting criteria1 data for valid comparison Dennis Excel Programming 2 December 4th 06 06:56 PM
can I use a cell content as a Criteria1 reference in the below Selection.AutoFilter statement? prady Excel Programming 1 July 28th 06 04:27 PM
Another Date related question.... Pete Dray Excel Worksheet Functions 7 June 18th 06 11:49 PM
printing related code question anny Excel Programming 1 May 15th 06 05:10 AM
I have a VB related question,... javabeens Excel Programming 1 June 7th 05 05:51 PM


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