Results 1 to 10 of 10

UserForm not Displaying Correctly

Threaded View

  1. #1
    Registered User
    Join Date
    01-05-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    17

    UserForm not Displaying Correctly

    Hello again,

    I have built a UserForm (Excel 2003) that looks up a Row dependant on Criteria and displays the values on the User Form. See Below

    Private Sub UserForm_Initialize()
     
    If Worksheets("Main Sheet").Range("E7") = ActiceCell Then RowNumber = 4
     
    If Worksheets("Main Sheet").Range("E8") = ActiveCell Then RowNumber = 5
     
    If Worksheets("Main Sheet").Range("E9") = ActiveCell Then RowNumber = 6
     
    If Worksheets("Main Sheet").Range("E10") = ActiveCell Then RowNumber = 7
     
    If Worksheets("Main Sheet").Range("E11") = ActiveCell Then RowNumber = 8
     
    If Worksheets("Main Sheet").Range("E12") = ActiveCell Then RowNumber = 9
     
    If Worksheets("Main Sheet").Range("E13") = ActiveCell Then RowNumber = 10
     
    If Worksheets("Main Sheet").Range("E14") = ActiveCell Then RowNumber = 11
     
    If Worksheets("Main Sheet").Range("E15") = ActiveCell Then RowNumber = 12
     
    If Worksheets("Main Sheet").Range("E16") = ActiveCell Then RowNumber = 13
     
    Worksheets("Sheet1").Select
     
    GetData
     
    End Sub
    The UserForm then runs the following.

    Private Sub GetData()
     
    Dim r As Long
     
    If IsNumeric(RowNumber.Text) Then
        r = CLng(RowNumber.Text)
     
    Else
        ClearData
        MsgBox "You have reached the Maximum"
        Exit Sub
     
    End If
     
    If r > 3 And r <= 35 Then
    TextBox1.Text = Cells(r, 1)
    TextBox2.Text = Cells(r, 2)
    TextBox3.Text = Cells(r, 3)
    TextBox4.Text = Cells(r, 4)
    TextBox5.Text = Cells(r, 5)
    TextBox6.Text = Cells(r, 6)
    TextBox7.Text = Cells(r, 7)
    TextBox8.Text = Cells(r, 8)
    TextBox9.Text = Cells(r, 9)
    TextBox10.Text = Cells(r, 10)
    TextBox11.Text = Cells(r, 11)
    TextBox12.Text = Cells(r, 12)
    TextBox13.Text = Cells(r, 13)
     
    ElseIf r = 3 Then
        ClearData
        MsgBox "You have reached the Maximum"
     
    End If
     
     
    End Sub
    The problem I'm having is that when running through the processes step by step it all works perfectly but when actualy running from a command button, its like it is to fast for it and the UserForm either does not display all the details or is a mixture of the current and previous Rows details.

    Does anyone know why or how to remedy this?


    Regards
    Last edited by Strugglin; 02-01-2009 at 09:00 AM.

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