Userform text box to last row of table

andstef

New Member
Joined
Jun 20, 2019
Messages
2
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:
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
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try replacing...

Code:
[COLOR=#333333]Set last_row = wltv.ListRows.Count[/COLOR]

with

Code:
With wltv
    Set last_row = .ListRows(.ListRows.Count)
End With

Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,844
Messages
6,181,294
Members
453,030
Latest member
PG626

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top