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
Bookmarks