Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
Hello,
I have this code that acts as a form of proactive error control. A critical piece of information (pn) has to be available in a second workbook to ensure the rest of application proceeds without error if it were to encounter missing information. So, this code references the critical data in the second workbook to see if that value exists. If it does, the application can proceed without fearing errors encountered from not finding required information in the second reference workbook. If the code reveals that the value doesn't exist in the reference box, the code stops, and opens up an application for the user the enter the missing information to the second workbook at that time. Worksheet 2 that holds the reference data, also has a worksheet based form in which the user can manipulate the data in the data worksheet.
In this instance, if the initial application reveals missing data, the user is forwarded to to the worksheet form to submit the missing data to the reference data worksheet. At that point, that missing value no longer poses a threat to error moving forward in the primary application (workbook) since the value is no longer missing from the database.
My question is, how do I resume my application's code once the user has successfully entered the data into the second workbook? I know that I could create a userform in the primary workbook to mimic what the worksheet based form in the second workbook does, but I'm hoping to avoid having to reinvent the wheel. I would be nice to use a process already established.
I hope I make sense, it's complicated to try and explain.
I have this code that acts as a form of proactive error control. A critical piece of information (pn) has to be available in a second workbook to ensure the rest of application proceeds without error if it were to encounter missing information. So, this code references the critical data in the second workbook to see if that value exists. If it does, the application can proceed without fearing errors encountered from not finding required information in the second reference workbook. If the code reveals that the value doesn't exist in the reference box, the code stops, and opens up an application for the user the enter the missing information to the second workbook at that time. Worksheet 2 that holds the reference data, also has a worksheet based form in which the user can manipulate the data in the data worksheet.
In this instance, if the initial application reveals missing data, the user is forwarded to to the worksheet form to submit the missing data to the reference data worksheet. At that point, that missing value no longer poses a threat to error moving forward in the primary application (workbook) since the value is no longer missing from the database.
My question is, how do I resume my application's code once the user has successfully entered the data into the second workbook? I know that I could create a userform in the primary workbook to mimic what the worksheet based form in the second workbook does, but I'm hoping to avoid having to reinvent the wheel. I would be nice to use a process already established.
I hope I make sense, it's complicated to try and explain.
Rich (BB code):
Sub permitintegrity()
'checks to ensure each booking has an assigned classification (D,F,C,T,P)
cntsh = 0 'count of visible sheets
With ws_front
.Unprotect
.Range("BT1") = "Permit integrity: "
.Range("BT1").HorizontalAlignment = xlRight
End With
For Each ws9 In wb_data.Worksheets
Debug.Print "Assessing: " & ws9.Name
If ws9.Visible = xlSheetVisible Then
ws_front.Range("BU1") = ws9.Name
ws_front.Range("BU1:BV1").HorizontalAlignment = xlCenterAcrossSelection
lrpda = Application.WorksheetFunction.Match("Facility Maintenance Activities", ws9.Columns(1), 0) - 3
For po = 13 To lrpda
pn1 = ws9.Cells(po, 3)
If pn1 <> "" Then
If Application.WorksheetFunction.CountIf(ws_permit.Columns(1), pn1) = 0 Then
ws_front.Range("BU1").Font.Color = RGB(192, 0, 0)
MsgBox "Worksheet: " & ws9.Name & Chr(13) & "Row: " & po & Chr(13) & "RID: " & ws9.Cells(po, 1), , "Invalid Permit Number: " & pn1
wb_permit.Windows(1).Visible = True
wb_permit.Worksheets("lists2").Activate
With wb_permit.Worksheets("Form")
.Activate 'reveals the worksheet based form in data workbook (wb_permit)
'user enters and submits entered data to wb_permit data worksheet for future reference
'when completed, submitting the data will hide wb_permit and I would like to see the initial code resume at this point?
'some action opposite 'stop'?
End With
End If
End If
Next po
End If
Next ws9
With ws_front
.Range("BU1") = "OK"
.Protect
End With
End Sub