+ Reply to Thread
Results 1 to 3 of 3

Countif declaration problem with ""word""

  1. #1
    Registered User
    Join Date
    09-20-2005
    Posts
    4

    Countif declaration problem with ""word""

    Thanks to those who previously helped me with a few problems. Here is another one.

    I am programming a database in which the user can specify a range of rows that should be used in the formula. For example, the user enters for beginning row 10 and for ending row 20, where x will be assigned 10 and y will be 20. In the used module the formula goes as follows...

    Worksheets("promotion").Range("L22").Formula = "=COUNTIF('Database'!$AR" & x & ":$AR" & y & ","T-shirt")"

    Now, the problem lies with the declaration of "T-shirt", where VBA expects the end of some expression. I need -> T-shirt <- to appear in the formula as -> "T-shirt" <- .
    How would I be able to assign "T-shirt" as a name, so that it does not cause any conflicts. Thanks for anyone who can give me some advice.

  2. #2
    Dave Peterson
    Guest

    Re: Countif declaration problem with ""word""

    Worksheets("promotion").Range("L22").Formula _
    = "=COUNTIF('Database'!$AR" & x & ":$AR" & y & ",""T-shirt"")"

    You have to double up those double quotes.

    mpot4 wrote:
    >
    > Thanks to those who previously helped me with a few problems. Here is
    > another one.
    >
    > I am programming a database in which the user can specify a range of
    > rows that should be used in the formula. For example, the user enters
    > for beginning row 10 and for ending row 20, where x will be assigned 10
    > and y will be 20. In the used module the formula goes as follows...
    >
    > Worksheets("promotion").Range("L22").Formula =
    > "=COUNTIF('Database'!$AR" & x & ":$AR" & y & ","T-shirt")"
    >
    > Now, the problem lies with the declaration of "T-shirt", where VBA
    > expects the end of some expression. I need -> T-shirt <- to appear in
    > the formula as -> "T-shirt" <- .
    > How would I be able to assign "T-shirt" as a name, so that it does not
    > cause any conflicts. Thanks for anyone who can give me some advice.
    >
    > --
    > mpot4
    > ------------------------------------------------------------------------
    > mpot4's Profile: http://www.excelforum.com/member.php...o&userid=27418
    > View this thread: http://www.excelforum.com/showthread...hreadid=474924


    --

    Dave Peterson

  3. #3
    JMB
    Guest

    RE: Countif declaration problem with ""word""

    try

    Worksheets("promotion").Range("L22").Formula = _
    "=COUNTIF('Database'!$AR" & x & ":$AR" & y & ",""T-shirt"")"

    "mpot4" wrote:

    >
    > Thanks to those who previously helped me with a few problems. Here is
    > another one.
    >
    > I am programming a database in which the user can specify a range of
    > rows that should be used in the formula. For example, the user enters
    > for beginning row 10 and for ending row 20, where x will be assigned 10
    > and y will be 20. In the used module the formula goes as follows...
    >
    > Worksheets("promotion").Range("L22").Formula =
    > "=COUNTIF('Database'!$AR" & x & ":$AR" & y & ","T-shirt")"
    >
    > Now, the problem lies with the declaration of "T-shirt", where VBA
    > expects the end of some expression. I need -> T-shirt <- to appear in
    > the formula as -> "T-shirt" <- .
    > How would I be able to assign "T-shirt" as a name, so that it does not
    > cause any conflicts. Thanks for anyone who can give me some advice.
    >
    >
    > --
    > mpot4
    > ------------------------------------------------------------------------
    > mpot4's Profile: http://www.excelforum.com/member.php...o&userid=27418
    > View this thread: http://www.excelforum.com/showthread...hreadid=474924
    >
    >


+ 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