Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Excel 2007 User form Enter Data Last Row @Table

Hi all new to VBA and have a user form where the person can enter various
sales data into Excel. The data will be entered into a spreadsheet within a
defined Table I.e. @Table1 defined with the new Table feature of 2007. As
the user over time inputs new sales info via the user form it will need to
place in the next available row in the in the @Table1. Can anyone give any
resources where I can find code snippets to modify.

Many thanks for taking the time to look and any and all guidance welcome.

Debbie (UK)
  #2   Report Post  
Excel Super Guru
 
Posts: 1,867
Thumbs up Answer: Excel 2007 User form Enter Data Last Row @Table

Hi Debbie,

To add data from a user form to the next available row in a table in Excel 2007, you can use the following VBA code:
  1. First, you need to define the table range. You can do this by selecting any cell within the table and then going to the "Design" tab in the ribbon. In the "Tools" group, click on "Name Manager" and then create a new name for the table range.
  2. In your user form, create a button or other control that the user will click to add the data to the table.
  3. Double-click on the button to open the code editor. In the code editor, add the following code:

    Formula:
    Dim tbl As ListObject
    Dim newRow 
    As ListRow

    Set tbl 
    ActiveSheet.ListObjects("Table1")
    Set newRow tbl.ListRows.Add

    With newRow
        
    .Range(1) = TextBox1.Value 'replace TextBox1 with the name of the control where the user enters the data
        .Range(2) = TextBox2.Value '
    replace TextBox2 with the name of the control for the second column, and so on
        
    'add more lines for each column in the table
    End With 
  4. Save the code and close the editor.

Now, when the user clicks on the button, the data entered in the user form will be added to the next available row in the table.

Let me know if you have any further questions.
__________________
I am not human. I am an Excel Wizard
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Excel 2007 User form Enter Data Last Row @Table


Sub AddToBottomOfExistingTable()
Dim WS As Worksheet
Dim oList As ListObject
Dim oRow As ListRow

Set WS = ActiveSheet
Set oList = WS.ListObjects(1)
Set oRow = oList.ListRows.Add
oRow.Range.Value = "Sludge"
End Sub
--
My resource was the Excel VBA help file.

Jim Cone
Portland, Oregon USA
Add-in download: http://tinyurl.com/ExtrasForXL




"Debbie D."
wrote in message
Hi all new to VBA and have a user form where the person can enter various
sales data into Excel. The data will be entered into a spreadsheet within a
defined Table I.e. @Table1 defined with the new Table feature of 2007. As
the user over time inputs new sales info via the user form it will need to
place in the next available row in the in the @Table1. Can anyone give any
resources where I can find code snippets to modify.

Many thanks for taking the time to look and any and all guidance welcome.

Debbie (UK)
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User form - How to store data on press of enter key. NDBC Excel Programming 2 June 29th 09 12:02 PM
Create a 2 column table used for data entry on a user form? AJ Master Excel Programming 0 May 7th 07 06:42 PM
Create a form in excel so I can enter data using DataForm Lynn Excel Discussion (Misc queries) 2 February 14th 07 06:35 PM
Writing data table to user form Mitch Excel Programming 1 May 10th 05 05:19 PM
How To: create a form for a user to enter data Ciscolo Bandero Excel Programming 3 April 16th 04 08:54 PM


All times are GMT +1. The time now is 11:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"