Userform text box to last row of table
Results 1 to 4 of 4

Thread: Userform text box to last row of table

  1. #1
    New Member
    Join Date
    Jun 2019
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Userform text box to last row of table

    Hello,

    Im trying to get the text from a textbox to the last row of a table.
    I do not want to add a new row, the row is already created by the macro and filled with data from column 1 to 6, I just want the text from the textbox to go in the last row of the seventh column.

    Here is the code I'm trying to use:
    HTML Code:
    Private Sub CommandButton1_Click()
    
    Dim the_sheet As Worksheet
    Dim wltv As ListObject
    Dim last_row As ListRow 
    
    Set the_sheet = Sheets("WorkLogT") 'WorkLogT is the name of the sheet
    Set wltv = the_sheet.ListObjects("WLT") 'WLT is the name of the table
    Set last_row = wltv.ListRows.Count
    
    last_row.Range(1, 7).Value = txt_worklog
    
    MsgBox "worklog submitted", 0, "Work log"
    
    Unload WorkLogUF
    End Sub
    Can someone please help?

    Thank you

  2. #2
    MrExcel MVP
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    18,830
    Post Thanks / Like
    Mentioned
    35 Post(s)
    Tagged
    5 Thread(s)

    Default Re: Userform text box to last row of table

    Try replacing...

    Code:
    Set last_row = wltv.ListRows.Count
    with

    Code:
    With wltv
        Set last_row = .ListRows(.ListRows.Count)
    End With
    Hope this helps!
    Last edited by Domenic; Jun 20th, 2019 at 07:17 PM.

  3. #3
    New Member
    Join Date
    Jun 2019
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Userform text box to last row of table

    It works !!!!!!!

    Thank you very much!

  4. #4
    MrExcel MVP
    Join Date
    Mar 2004
    Location
    Canada
    Posts
    18,830
    Post Thanks / Like
    Mentioned
    35 Post(s)
    Tagged
    5 Thread(s)

    Default Re: Userform text box to last row of table

    You're very welcome!

    Cheers!

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •