+ Reply to Thread
Results 1 to 4 of 4

Adding single listobject, selected Columns[Name] to an array

  1. #1
    Registered User
    Join Date
    09-27-2020
    Location
    Australia
    MS-Off Ver
    Office 360 Desktop
    Posts
    4

    Talking Adding single listobject, selected Columns[Name] to an array

    Hi

    I'd like a little help please, I've been googling for half an hour and can't find it online

    I can assign all values in my listobject to an array like so
    Please Login or Register  to view this content.
    But what if I want to create my array using only a few listobject columns, referred to by name

    Is it possible to create an array in which for example
    • First column: Range(mytable.Name & "[First Name]")
    • Second column: Range(mytable.Name & "[Second Name]")
    • Third Column: Range(mytable.Name & "[Other Column]")
    They all have the same number of rows, its all from one column

    Reason, I'd like to be able to control which columns go in to which column of the array, and for them to be added by name so that if I insert a column later on it won't break my vba

    Trying currently, not working
    Please Login or Register  to view this content.
    Last edited by sabooru; 12-16-2020 at 05:49 PM.

  2. #2
    Registered User
    Join Date
    03-22-2019
    Location
    Los Angeles
    MS-Off Ver
    2013
    Posts
    34

    Re: Adding single listobject, selected Columns[Name] to an array

    It's possible. The for loop will show you the data that is stored. Adjust the table/column name to match yours.
    Try this:

    Please Login or Register  to view this content.
    Last edited by mrbarba; 12-16-2020 at 10:32 PM.

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

    Re: Adding single listobject, selected Columns[Name] to an array

    Quote Originally Posted by sabooru View Post
    Is it possible to create an array in which for example
    • First column: Range(mytable.Name & "[First Name]")
    • Second column: Range(mytable.Name & "[Second Name]")
    • Third Column: Range(mytable.Name & "[Other Column]")
    They all have the same number of rows, its all from one column

    Reason, I'd like to be able to control which columns go in to which column of the array, and for them to be added by name so that if I insert a column later on it won't break my vba
    Do you want to create 2D array consists of above columns?
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-27-2020
    Location
    Australia
    MS-Off Ver
    Office 360 Desktop
    Posts
    4

    Re: Adding single listobject, selected Columns[Name] to an array

    Thanks very much to both of you for giving your time

    I used jindon's method. I was looking to make a 2D array which I should have specified.
    Very nice concise method thanks

+ 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. Adding Single Cell Array Constants
    By excelformulae in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-14-2019, 11:09 AM
  2. [SOLVED] Adding numbers from an array into a single cell
    By realdemigod in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 10-25-2016, 08:58 AM
  3. How to turn Listobject into an Array
    By shawnvw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-07-2015, 01:07 AM
  4. How can I find out which listobject row is selected?
    By OldManExcellor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2014, 01:22 PM
  5. C# DataTable and adding new columns to a ListObject
    By DaveEvans in forum Access Tables & Databases
    Replies: 1
    Last Post: 12-22-2011, 07:53 AM
  6. Adding data to ListObject fails
    By lmolenaar in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-12-2011, 06:46 AM
  7. Replies: 7
    Last Post: 02-27-2008, 03:53 PM

Tags for this Thread

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