+ Reply to Thread
Results 1 to 6 of 6

VBA to populate Table

  1. #1
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,262

    VBA to populate Table

    Hi All

    For once and for all I need to get assistance to understand this concept. I have attached my workbook.
    This code populates the Table and then moves down to next row...It however only populates from 2 row.
    Please Login or Register  to view this content.
    If I change this line of code
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.
    it populates the first row but on the next populate it overwrites the existing code
    There must be a way to add something like this
    Please Login or Register  to view this content.
    to make it populate the first row and then the second third etc
    Attached Files Attached Files

  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: VBA to populate Table

    Since you're using an Excel Table....You should take advantage of its features.

    Try something like this:
    Please Login or Register  to view this content.
    Also....you should ALWAYS have "Option Explict" at the top of every VBA Module to prevent inadvertent, on-the-fly, variable delarations and usage.

    Is that something you can work with?
    Last edited by Ron Coderre; 09-09-2016 at 09:10 AM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,262

    Re: VBA to populate Table

    Oh My word Ron

    Thanks so much... It's as if a weight has been lifted off my shoulders.
    Do you perhaps have a helpful link I can read up on Tables.

    What do you mean by :

    to prevent inadvertent, on-the-fly, variable delarations and usage.

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

    Re: VBA to populate Table

    Option Explicit

    That statement acts like a spell-checker in your VBA code. If you misspell a variable name...
    example:
    Please Login or Register  to view this content.

    The code will compile, but will throw an error when you run it because Wks was never actually set.
    If Option Explict was used. Running Debug.Compile from the menu would flag Wksht as an error.

    If you're looking for a great website to learn how to used VBA on Excel Tables, you can't do much better than Jan Karel Pieterse's site:
    http://www.jkp-ads.com/Articles/Excel2007TablesVBA.asp

    I hope that helps.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,262

    Re: VBA to populate Table

    Ron you've been an absolute star. Am gonna go on the site to read up.
    A Quick question. You will notice by the below code that i have adapted it for the bigger Picture.

    Please Login or Register  to view this content.
    I need this part to be added:
    Please Login or Register  to view this content.
    Would that be the correct syntax

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

    Re: VBA to populate Table

    If it works....then YES

    You might even be able to use something like this: (untested)

    Please Login or Register  to view this content.

+ 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: 1
    Last Post: 05-14-2016, 03:05 PM
  2. Finding a macro that will populate a table from another table based on a columns values
    By Daril_Ghiroza in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2015, 02:26 PM
  3. [SOLVED] Formula for copying over relevant data from one table to populate another table
    By amasson in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-19-2013, 06:11 AM
  4. Replies: 2
    Last Post: 04-15-2013, 07:22 AM
  5. [SOLVED] Formula for copying over relevant data from one table to populate another table
    By amasson in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 02-25-2013, 12:41 PM
  6. [SOLVED] How to populate a table based on the searched values in a pivoted table
    By Kausty88 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2012, 06:11 AM
  7. Reference / retrieve data from a table and populate a table in a different workbook?
    By philuptuous in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-17-2012, 06:21 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