Results 1 to 7 of 7

Macro to fill up a table from a User Form information

Threaded View

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    4

    Macro to fill up a table from a User Form information

    Hello Everyone,

    I have found this forum really helpful, and I have decided to join. I have a question. Any help is very much appreciated.

    I have an excel table that contains many columns with different information that is imported from a macro User Form. The problem that I found is that if I add more columns in between, I have to go and change all the row-column references. This is basically what I have:

    'SAVE BUTTON FUNCTION:
    
    Private Sub SaveButton_Click()
    
    Dim emptyRow As Long
    
    'Make Sheet1 Active
    Sheets(1).Activate
    
    'Determine emptyRow
    emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
    
    'Export Data to worksheet
    Cells(emptyRow, 1).Value = FromComboBox.Value & "-" & ToComboBox.Value
    Cells(emptyRow, 2).Value = LineComboBox.Value
    Cells(emptyRow, 3).Value = GWTextBox.Value
    Cells(emptyRow, 4).Value = MPTextBox.Value
    Cells(emptyRow, 12).Value = TextBox3.Value
    Cells(emptyRow, 13).Value = ConManagerComboBox.Value
    
    End Sub
    This code is simple. Just saves whatever is written in the form's text box, combobox, etc to the excel sheet. I think the easier solution is to define a table, then name the columns to make them absolute references, so if I put cells in between, it wont enter the info in the wrong column. The problem is that I haven't found the way or probably I am trying to apply a wrong concept.

    I will greatly appreciate your help

    Thank you.

    Diego C.
    Last edited by Cutter; 07-30-2012 at 03:20 PM. Reason: Added code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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