+ Reply to Thread
Results 1 to 3 of 3

Cell references in macros

  1. #1
    Dan
    Guest

    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. #2
    JR in NC
    Guest

    RE: 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. #3
    Dan
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1