+ Reply to Thread
Results 1 to 7 of 7

Code help: Update new row of Table (ListObject) via UserForm

Hybrid View

  1. #1
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Code help: Update new row of Table (ListObject) via UserForm

    Hi guys,

    i am trying to update a new row of a Table (ListObject) making use of a simple UserForm, but am struggling with the code.

    i would really appreciate if someone could take a look.

    See attached

    Thank you in advance!
    Attached Files Attached Files
    Last edited by onmyway; 01-27-2015 at 04:11 AM.

  2. #2
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Code help: Update new row of Table (ListObject) via UserForm

    This seems to work:
    oNewRow.Range(1, 4).Value = "Value For New cell"
    oNewRow.Range(1, 5).Value = Me.TextBox1.Value
    Acts 4:12
    Salvation is found in no one else, for there is no other name under heaven given to mankind by which we must be saved.

  3. #3
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Code help: Update new row of Table (ListObject) via UserForm

    Hi natefarm

    I am trying to get away from referencing an absolute Cell. i want to make use of a method where I reference a Column name, and where it will not make a difference whether the position of the Column changes within my Table. That way i can add columns, move column etc., and don't need to change my code the whole time.

  4. #4
    Valued Forum Contributor natefarm's Avatar
    Join Date
    04-22-2010
    Location
    Wichita, Kansas
    MS-Off Ver
    2016
    Posts
    1,020

    Re: Code help: Update new row of Table (ListObject) via UserForm

    I was just going with the code you had provided. In what way do you intend to "reference a column name"?

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Code help: Update new row of Table (ListObject) via UserForm

    One way:
    oNewRow.Range(1, myTable.ListColumns("Column4").Index).Value = "Value For New cell"
    oNewRow.Range(1, myTable.ListColumns("Column5").Index).Value = Me.TextBox1.Value
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Code help: Update new row of Table (ListObject) via UserForm

    Or using ListColumns:

    With myTable
        .ListColumns("Column4").DataBodyRange.Cells(oNewRow.Index).Value = "Value For New cell"
        .ListColumns("Column5").DataBodyRange.Cells(oNewRow.Index).Value = Me.TextBox1.Value
    End With

  7. #7
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Code help: Update new row of Table (ListObject) via UserForm

    This is great, thank you all!

+ 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. [SOLVED] Get Cursor Location in a ListObject table
    By snapfade in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-19-2014, 05:24 PM
  2. [SOLVED] Converting Query Table to ListObject
    By x10sion in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2013, 06:56 AM
  3. Table ListObject Filter
    By efernandes67 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2011, 07:40 AM
  4. Update table from a userform with controls
    By mohanvp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2011, 03:56 AM
  5. Update code on a UserForm Via Macro
    By JimmyA in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-09-2009, 05:30 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