+ Reply to Thread
Results 1 to 2 of 2

UserForm data not working outside VBA viewer!

  1. #1
    Registered User
    Join Date
    02-17-2011
    Location
    Houston, Texas, USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    UserForm data not working outside VBA viewer!

    Hey guys,

    I have created a userform with a few text boxes to be populated into a a series of fields. The idea is that when you press ENTER, the fields are populated into a series of fields in Sheet1 (In row 4, columns C through I). The code I have works when I test it in the VBA viewer, but when I exit the viewer and try it from the sheet, it doesnt work.

    The way it works:

    1) You go to Sheet1 and press the "Enter New Deal" button which opens up the user form.
    Here's the code for this button.

    Sub OpenForm()
    '
    Dim ABC As New UserForm1
    ABC.Show

    End Sub

    2) You enter in the relevant information in the user form. Press Enter.
    The ENTER button creates a new row in Row 4 and populates the fields in row 4, columms C through I.
    Here's the code for the ENTER button.

    Private Sub CommandButton1_Click()
    Sheets("Sheet1").Select
    Rows("4:4").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("C4") = UserForm1.TextBox1.Value
    Range("D4") = UserForm1.TextBox9.Value
    Range("E4") = UserForm1.TextBox2.Value
    Range("F4") = UserForm1.TextBox7.Value
    Range("G4") = UserForm1.TextBox6.Value
    Range("H4") = UserForm1.ComboBox2.Value
    Range("I4") = UserForm1.ComboBox3.Value
    Range("J4") = UserForm1.TextBox8.Value

    End Sub

    This seems to work when I test it in the VBA viewer, but when i try it throught the spreadsheet, nothing populates in the designated fields. Not sure where or what the disconnect is.


    Let me know if this doesnt make sense. Thanks in advance.
    Last edited by ibrahio; 02-18-2011 at 06:10 PM. Reason: SOLVED

  2. #2
    Registered User
    Join Date
    02-17-2011
    Location
    Houston, Texas, USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: UserForm data not working outside VBA viewer!

    SOLVED!

    Sub OpenForm()
    '
    Dim ABC As New UserForm1
    ABC.Show

    End Sub

    was changed to

    Sub OpenForm()

    UserForm1.Show

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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