+ Reply to Thread
Results 1 to 7 of 7

Cant Figure Out Syntax For Range As A Variable

  1. #1
    Forum Contributor
    Join Date
    10-29-2019
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    156

    Cant Figure Out Syntax For Range As A Variable

    Hi, Im having a problem with using range variables, basically the CriteriaValue variable refuses to work correctly, & gives errors whenever its called ... Im pretty sure its the syntax, & not sure how to fix it ...

    This is a basic countif script, but cant get the main variable to use the countif to work, this is stored in CriteriaValue.

    Thanks

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,844

    Re: Cant Figure Out Syntax For Range As A Variable

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,441

    Re: Cant Figure Out Syntax For Range As A Variable

    Can you explain what you think should be happening?


    Currently CriteriaValue is a range reference with the value of 10. When you use it in the following line it actually reads
    Please Login or Register  to view this content.
    HighestCurentValue = Range(10).Value

    Obviously Range(10) is not valid.

    The same will be true in the CountIf line of code
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor
    Join Date
    10-29-2019
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    156

    Re: Cant Figure Out Syntax For Range As A Variable

    Thanks @Mumps1,

    But the msgbox doesnt seem to come up in the script for some reason?

    Thanks

  5. #5
    Forum Contributor
    Join Date
    10-29-2019
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    156

    Re: Cant Figure Out Syntax For Range As A Variable

    Hi Andy Pope,

    Yea, i wanted the value in cell a1 as a variable, i wasnt sure of the syntax ...

  6. #6
    Forum Contributor
    Join Date
    10-29-2019
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    156

    Re: Cant Figure Out Syntax For Range As A Variable

    Nm @Mumps1, i fixed it ...

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,844

    Re: Cant Figure Out Syntax For Range As A Variable

    Glad it worked out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. cell range variable syntax
    By Estaban9850! in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-28-2016, 09:44 AM
  2. [SOLVED] Syntax for Using Range with a Variable Column
    By Gard5096 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-31-2013, 12:36 PM
  3. Countifs VBA Syntax - variable row range
    By rasonline in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2011, 04:16 PM
  4. Refer to a range(row 20 : variable), syntax help
    By VBAHelpMe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2009, 09:01 AM
  5. Syntax for Range command with a variable
    By nebb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-11-2007, 12:14 PM
  6. syntax - range name as a variable
    By Peter Morris in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2006, 02:15 PM
  7. Syntax to Set variable range
    By Mike Fogleman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2005, 05:15 PM

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