+ Reply to Thread
Results 1 to 3 of 3

selecting activecell with range

  1. #1
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    selecting activecell with range

    Why does this code work? I always get confused as to how vba reads range/cell inputs. Like, does it return a number or a string and can range/cell read a number or a string. Any insight?

    Please Login or Register  to view this content.
    Last edited by ammartino44; 09-28-2015 at 12:42 PM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,912

    Re: selecting activecell with range

    The range object of a worksheet takes different values and creates a range object from those inputs.

    The most commonly used is just an address string:

    Please Login or Register  to view this content.
    Another way is to use two range objects, used to determine the "corners" of a range
    Please Login or Register  to view this content.
    though the corners used don't really matter - this is the same range as the example immediately above - what matters is the first and last rows and the left-most and right-most columns to define the block of cells

    Please Login or Register  to view this content.
    Your example is just a variation on this technique: Activecell is a range, and Cells(r,c) is another range

    Please Login or Register  to view this content.
    And you can mix strings and range objects as the anchors, so this works as well:

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: selecting activecell with range

    It selects a Range. In this instance your variables r and c need too be defined. r would represent a number value for the row, and c would represent a number value for the column. Therefore from the activecell it will offset to values defined to select a range. For example in this scenario.

    Please Login or Register  to view this content.
    It would select row 6 column 3 or cells(6,3) and select the whole range between that cell and the activecell.

+ 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. Copying an activecell range and pasting to another activecell range
    By Londonbound in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2014, 07:41 AM
  2. selecting range from Activecell to last entry in the same row as active cell
    By lbesley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2014, 03:24 AM
  3. Selecting Activecell and cell next to the Activecell
    By Raghukumarn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-31-2013, 06:32 AM
  4. Selecting a range of cells using ActiveCell where the start point is variable
    By jshaw82 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-12-2013, 05:54 AM
  5. Selecting from point X to end, and sliding ActiveCell over or down
    By petalred in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2008, 03:35 PM
  6. Selecting Range next to ActiveCell
    By ChrisF79 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2008, 02:28 PM
  7. Replies: 1
    Last Post: 07-31-2006, 07:33 AM

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