+ Reply to Thread
Results 1 to 7 of 7

VBA code for passing a variable name as a paramter to Range object

  1. #1
    Forum Contributor
    Join Date
    02-22-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    102

    VBA code for passing a variable name as a paramter to Range object

    Hello,

    unsure if my query is logical. I have stored the column number in D5 and this should be used as an input to range object. For instance,the below code works well, but instead of referring B:B ( highlighted) directly i need to use the value stored in D5 ( which will be 2 in this case)

    Please Login or Register  to view this content.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA code for passing a variable name as a paramter to Range object

    Maybe

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-19-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: VBA code for passing a variable name as a paramter to Range object

    shg, Did you intend to write....

    Please Login or Register  to view this content.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA code for passing a variable name as a paramter to Range object

    Either would work, depending in the cell contents.

  5. #5
    Registered User
    Join Date
    05-19-2011
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: VBA code for passing a variable name as a paramter to Range object

    Per the OP, the cell contents is a Column Number.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA code for passing a variable name as a paramter to Range object

    Then Columns it is. Range would be more versatile, but you're exactly right for the OP's stated plan.
    Last edited by shg; 07-07-2012 at 04:52 PM.

  7. #7
    Forum Contributor
    Join Date
    02-22-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: VBA code for passing a variable name as a paramter to Range object

    Thanks Shg / JS411 for your support. It works. aplogies for delayed submission as i had just accessed my account.

+ 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