Results 1 to 1 of 1

Hidden Userform shows instead of Worksheet after Application.Goto

Threaded View

  1. #1
    Registered User
    Join Date
    07-13-2011
    Location
    Boston, MA USA
    MS-Off Ver
    Excel 2010
    Posts
    28

    Hidden Userform shows instead of Worksheet after Application.Goto

    Circumstances:
    frmEvaluationProc userform is hidden and frmSHLDRProc is shown. (Modal)
    In the frmSHLDRProc module, in a button click Sub to show a protected worksheet (Table15-5), the worksheet is activated, I fill some worksheet cells with userform field values, I determine the row to display the worksheet at, I hide fmrSHLDRProc, and I use Application.Goto to display the worksheet.

    Results:
    The frmSHLDRProc userform disappears and the worksheet appears starting at the row I want. But, it quickly disappears, and the userform frmEvaluationProc (not even frmSHLDRProc from which I came) gains focus! I can use the taskbar to access the worksheet and it functions as it's supposed to. I double click a cell in the worksheet to return to fmrSHLDRProc. Other problems then occur, but for now, I'd just like to get the worksheet to gain focus when it should.

    Below, I'm including my code in frmSHLDRProc module that executes when the user clicks the button to show the worksheet Table 15-5. Any help would be greatly appreciated!
    Private Sub cmdTable15_5_Click()
    
    Application.Sheets("Table15-5").Activate
    
    '  if data exists, also set row, class & grade
    '
    Range("B4") = txtDx_ID
    If txtDxClass >= 0 Then
        Range("B6") = txtDxClass
        Range("C6") = txtDxGrade
        Range("A3") = txtDxRow
        Range("J4") = txtSubDxDesc
        Range("D6") = txtSumDxImp
    Else
        Range("B6") = ""
        Range("C6") = ""
        Range("A3") = ""
        Range("J4") = ""
        Range("D6") = ""
    End If
    
    If txtSumAdjDxImp >= 0 Then
    '    MsgBox "txtSumAdjDxImp > or = 0. Value is: " & txtSumAdjDxImp, vbOKOnly
        Range("C5") = txtAdjGrade
        Range("D5") = txtSumAdjDxImp
    Else
        Range("C5") = ""
        Range("D5") = ""
    End If
    
    Call SetTable15_5_StartRow
    
    frmSHLDRProc.Hide
    Sheets("Table15-5").Protect Password:="xxxxx", userinterfaceonly:=True
    Sheets("Table15-5").Visible = True
    Application.Goto Range(rFoundDx.Address), True
    End Sub
    ----------------------------------------------------------
    
    Private Sub SetTable15_5_StartRow()
    
    FindWhat = txtDx_ID
    
    '   Finds FIRST range containing Dx
    
    With Sheets("Table15-5").Range("A:A")
    Set rFoundDx = .Find(What:=FindWhat, _
                    After:=.Cells(.Cells.Count), _
                    LookIn:=xlValues, _
                    LookAt:=xlWhole, _
                    SearchOrder:=xlByRows, _
                    SearchDirection:=xlNext, _
                    MatchCase:=False)
        If rFoundDx Is Nothing Then
            MsgBox "Set Start Row: Dx not found in Table 15-5. Pgm error", vbOKOnly
            Set rFoundDx = Range("A11")
            Exit Sub
        End If
    End With
    End Sub
    Last edited by bdoodle; 01-17-2012 at 05:05 PM.

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