+ Reply to Thread
Results 1 to 7 of 7

Create VB array from cell set

  1. #1
    Registered User
    Join Date
    03-31-2014
    Location
    England
    MS-Off Ver
    Excel 2011 for mac
    Posts
    13

    Create VB array from cell set

    Hi, still on a rapid learning curve with VB in excel. I current have a Macro that uses the following array,

    Please Login or Register  to view this content.
    However I would rather have the names across a cell range, and the array to get each cell value.

    Name
    1 Tim Wilkinson
    2 David Brooks
    3 Jason Goodwin

    So something like,

    Please Login or Register  to view this content.
    Is this a. possible, b.relatively easy?

    Any guidance would be greatly appreciated thankyou.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Create VB array from cell set

    You can either just reference the range directly:
    Please Login or Register  to view this content.
    or transfer the range to an array and then loop through that:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-31-2014
    Location
    England
    MS-Off Ver
    Excel 2011 for mac
    Posts
    13

    Re: Create VB array from cell set

    Thank you very much, i went with your second option in the end, did exactly what i wanted. A quick follow up question however, once the code has run
    Please Login or Register  to view this content.
    for each `r` in the range, is there a way of using them further down the sub, and call them specifically, for example something like
    Please Login or Register  to view this content.
    or would i just have to specify each cell individually as B2, B3, B4 etc.

    I hope that makes some sort of sense.

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,676

    Re: Create VB array from cell set

    Since r refers the range B2:B4,

    First value of r is Range("B2").offset(0,0)
    Second value of r is Range("B2").offset(1,0)
    Third value of r is Range("B2").offset(2,0)

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Create VB array from cell set

    If you used Stephen's second option then you should have the values stored in the array v.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,670

    Re: Create VB array from cell set

    Something like
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    03-31-2014
    Location
    England
    MS-Off Ver
    Excel 2011 for mac
    Posts
    13

    Re: Create VB array from cell set

    sorry i mis typed and meant i went with Stephens first option. Thank you though, still helpful!

+ 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. Replies: 6
    Last Post: 09-25-2013, 10:08 PM
  2. Create Date Array with all dates between Min and Max (Single Cell Solution)
    By gus_7475 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-24-2013, 12:36 PM
  3. Using Text From Cell to Help Create Lookup Array
    By Talofa in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-13-2013, 04:56 AM
  4. Replies: 1
    Last Post: 05-26-2012, 03:03 AM
  5. [SOLVED] Need to create a dynamic array of cell references for MINVERSE
    By ATLGator in forum Excel General
    Replies: 1
    Last Post: 03-26-2012, 10:49 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