status not being transferred to sub routine

SeniorTom

Board Regular
Joined
Jun 5, 2017
Messages
96
I have a form that prompts the user to continue or cancel. If they select the wrong file I cancel and want to give a message and restart. I need to check myFileStatus As Boolean but it is empty when I return to Public Sub OKButton_Click(). Your help is appreciated.

Tom




Code:
[COLOR=#0000cd]' located in RESPONSE.xlsm - UpdateForm (code) OKButton - click[/COLOR]

Public Sub OKButton_Click()
Dim msg As String
ThisWorkbook.Activate
Call Sheet1.update_trackingFile
Unload UpdateForm
Debug.Print myFileStatus                        ' trying to get status so I can cancel message with an If... then
msg = " Your emails have been sent" & vbNewLine
msg = msg & " confirm in CP sent folder"
MsgBox msg
End Sub



'================================================================================
[COLOR=#0000cd]' This is located in RESPONSE.xlsm -Sheet1(code) General - update_trackingFile[/COLOR]
  
' Right click any cell to start the process of emailing responses to signup requests.
  
        Public mailcount As Long                       ' number of emails sent
        Dim RosterFileName As Variant
        Dim ResponseFileName As Workbook
        Dim mylocalpath As Variant
        Dim MyActivefile As Variant
        Const emailColumn As String = "C"           ' column in response file for e-mail address
        Dim lastRow As Long
[COLOR=#ff0000]        Public myFileStatus As Boolean                ' I'm trying to use this in another subroutine[/COLOR]
        Dim fullpath As Variant
___________________________________________________________________________________________
Public Sub update_trackingFile()
' Routing to take responses from a google form's spreadsheet. It will also email a response to
' the requester's email

' makes sure the Roster file is open
mylocalpath = ThisWorkbook.Path
MyActivefile = ThisWorkbook.FullName
Set ResponseFileName = ThisWorkbook
ResponseFileName.Activate
With Sheet1
' confirm that the roster file is open and the version you want
Call OfferRosterFile
    If myFileStatus = False Then
            Exit Sub
    Else
    End If
' Insert the email address in the response file
Call insertEmail

' send an email to all that have responded
Call Send_emails            '****** send to must be adjusted before release

End With
End Sub
...
...
...

If Not UCase(RosterFileName) Like FilterName Then
        MsgBox "You must Select a Roster file"
         myFileStatus = False
         Exit Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,225,390
Messages
6,184,685
Members
453,252
Latest member
ok_lets

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top