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
 
That should work yes.
Odd.

I might be missing something obvious, but have a read through this as well: Excel VBA declare Global Variable and variable scope

XflpXwQ.png
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,216,073
Messages
6,128,645
Members
449,461
Latest member
kokoanutt

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