+ Reply to Thread
Results 1 to 2 of 2

learning Excel VBA. Query on syntax for range function

  1. #1
    Registered User
    Join Date
    12-18-2012
    Location
    singapore
    MS-Off Ver
    Excel 2010
    Posts
    19

    learning Excel VBA. Query on syntax for range function

    Hi. i have seen a couple of examples on how to define range/ cells.

    There is a particular one which i am curious about

    Range(counter & ":" & counter).Value


    counter defines an integer variable.
    does the above statement means selecting the entire row, of which counter specifies?

    for the e.g. entire row 1 etc.



    Also, typical examples shows the defining of range as Range("A1:B3"). The entire range is in quotes. Why is it that for the first example, only the colon is in quotes?



    Thank you

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: learning Excel VBA. Query on syntax for range function

    In the first example, Excel recognizes that string arithmetic is being performed and treats it like text.
    You see the same behavior in a worksheet....
    A1: 1
    B1: A1&":"&A1

    You might think that, because A1's contents are numeric, an error would be thrown.
    Instead, however, B1 returns: 1:1

    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

+ 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