+ Reply to Thread
Results 1 to 6 of 6

Thread: UserForm terminates without result

  1. #1
    Registered User
    Join Date
    10-20-2011
    Location
    vienna
    MS-Off Ver
    Excel 2007
    Posts
    5

    UserForm terminates without result

    Hi!

    I'm trying to create a UserForm which should ask for few info, than put the values (and some other values taken from the worksheet) into the sheet. for some reason only the first value is copied into the cell, afterwards the UserForm closes without any error message... I have no idea what ca be wrong... here is the code that runs when the "enter" button of the UserForm is pressed..

    Private Sub EnterBt_Click()
    
    Dim emptyRow As Long
    Dim HeadingCounter As Integer
    Dim QuestionCounter_1 As Integer
    
    Sheets(1).Activate
    
    QuestionCounter_1 = Range("B2").Value
    HeadingCounter = Range("B1").Value
    emptyRow = WorksheetFunction.CountA(Range("a:a")) + 1
    
    
    Cells(emptyRow, 2).Value = QuestionTBox.Value
    Cells(emptyRow, 3).Value = PageTBox.Value
    Cells(emptyRow, 4).Value = QuestionCounter_1
    Cells(emptyRow, 5).Value = Chr(HeadingCounter)
    End Sub
    Any ideas?
    Thanks!!!!
    Mickey
    Last edited by mickey001; 01-17-2012 at 10:51 AM.

  2. #2
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: UserForm terminates without result

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  3. #3
    Registered User
    Join Date
    10-20-2011
    Location
    vienna
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: UserForm terminates without result

    thanks, fixed.

  4. #4
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: UserForm terminates without result

    Try
    Option Explicit
    Private Sub EnterBt_Click()
    
    Dim emptyRow As Long
    Dim HeadingCounter As Integer
    Dim QuestionCounter_1 As Integer
    
    With Sheets(1)
    
    QuestionCounter_1 = .Range("B2").Value
    HeadingCounter = .Range("B1").Value
    emptyRow = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
    
    
    .Cells(emptyRow, 2).Value = QuestionTBox.Value
    .Cells(emptyRow, 3).Value = PageTBox.Value
    .Cells(emptyRow, 4).Value = QuestionCounter_1
    'not sure what this is
    .Cells(emptyRow, 5).Value = Chr(HeadingCounter)
    End With
    End Sub
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  5. #5
    Registered User
    Join Date
    10-20-2011
    Location
    vienna
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: UserForm terminates without result

    I think it works! thanks!!!

    fyi:

    HeadingCounter = .Range("B1").Value

    ....

    'not sure what this is
    .Cells(emptyRow, 5).Value = Chr(HeadingCounter)
    B1 contains the value "65" in the beginning, which will be increased by 1 with the entry of each record, so with chr(HeadingCounter) I can assign letters A,B,C,... to each record... Is there any better way to do that?

    thanks again,
    Mickey

  6. #6
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: UserForm terminates without result

    Thanks for the rep. Your chr code should be fine until the number exceeds 26
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

+ Reply to Thread

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.2.0