Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Cell references in macros

I have a macro with the following statement:


Selection.AutoFilter Field:=1, Criteria1:="=5/15/2006", Operator:=xlAnd _
, Criteria2:="<=5/28/2006"

I want to replace the two dates with references to the values in cells B1
and B2 in the sheet "Macro Data". How do I do this?

Dan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cell references in macros

Dan, you can play with this: (values in A1 & A2)

Selection.AutoFilter Field:=1, Criteria1:="=" & Cells(1, 1),
Operator:=xlAnd _
, Criteria2:="<=" & Cells(2, 1)

jr


"Dan" wrote:

I have a macro with the following statement:


Selection.AutoFilter Field:=1, Criteria1:="=5/15/2006", Operator:=xlAnd _
, Criteria2:="<=5/28/2006"

I want to replace the two dates with references to the values in cells B1
and B2 in the sheet "Macro Data". How do I do this?

Dan

  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Cell references in macros

JR,

Thank you for your reply.

I have a date in both B1 and B2 (sheet "Macro Data"). In my macro, I have
the following code:

Dim EndDate As Date
Dim StartDate As Date

StartDate = Sheets("Macro Data").Cells("B1")
EndDate = Sheets("Macro Data").Cells("B2")

Then I am going to use StartDate and EndDate in the AutoFilter statement
that I gave in my previous message. However, the above statements are giving
me error 13 (type mismatch). Can you help me with what's wrong with what I'm
doing? Thanks!

Dan


"JR in NC" wrote:

Dan, you can play with this: (values in A1 & A2)

Selection.AutoFilter Field:=1, Criteria1:="=" & Cells(1, 1),
Operator:=xlAnd _
, Criteria2:="<=" & Cells(2, 1)

jr


"Dan" wrote:

I have a macro with the following statement:


Selection.AutoFilter Field:=1, Criteria1:="=5/15/2006", Operator:=xlAnd _
, Criteria2:="<=5/28/2006"

I want to replace the two dates with references to the values in cells B1
and B2 in the sheet "Macro Data". How do I do this?

Dan

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
Excel 2003 macros set relative cell references JPI Excel Discussion (Misc queries) 7 May 21st 07 05:08 AM
cell references in macros Dave F Excel Discussion (Misc queries) 3 November 28th 06 05:19 PM
Relative (vs. Absolute) Cell References with macros Claude S. Weiller Excel Discussion (Misc queries) 1 August 3rd 06 08:56 PM
Using cell references in Excel Macros Michelle Ann Excel Programming 1 August 18th 04 01:43 AM
Relative Cell References in Macros Barry Staples Excel Programming 4 January 25th 04 07:44 AM


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