title: Does my parameter value store its value i.e. memory - if button clicked divert macro to second macro
body: <p>Here is my code of two sub procedures, one function, two other sub procedures for macro protection (irrelevant). The last sub procedure, <code>sub manual_date()</code> is the center of my inquiry. How could I divert the macro code if the user of this macro choose to manually input their own date. The main code is highlighted as the center code screen. I know I could very easily copy and paste as a solution. I am interested in an advanced coding strategy.</p>
  <pre><code>Option Explicit
  
  Sub Client_Dirty_Recon()
  
  Dim Date_minus_one As Date              ' Date &amp; weekend logic
  Dim answer As Long                      ' Date &amp; weekend logic
  Dim brow As Long                        ' Last filled cell in column
  Dim yrow As Long                        ' Last filled cell in column
  Dim nRow As Long                        ' Last filled cell in column
  Dim c As Range                          ' rngWatch.Cells(i, 1).Value
  Dim oldStatusBar As Variant             ' Save StatusBar status
  Dim Client_path As String               ' Range(&quot;Path&quot;)
  Dim wb As Workbook                      ' ThisWorkbook
  Dim wbDirty As Workbook                 ' Workbooks.Open(Client_path)
  Dim rngReconcile As Range               ' wb.Sheets(1).Range(&quot;K:K&quot;)
  Dim rngWatch As Range                   ' wbDirty.Sheets(1).Range(&quot;A:A&quot;)
  Dim rngNew As Range                     ' wbNew.Sheets(1).Range(&quot;A:A&quot;)
  Dim failed_count As Long
  Dim FS
  
  
  oldStatusBar = Application.DisplayStatusBar     'optional - save StatusBar
  Application.DisplayStatusBar = True             'optional - turn on StatusBar
  Application.ScreenUpdating = False              'optional - screen won't flash
  Application.StatusBar = &quot;Opening workbooks...&quot;  'optional - Update user
  
  Call Unprot
  
  Date_minus_one = Date
  answer = IsMonday(Date_minus_one)
  
  If answer = True Then
  Date_minus_one = Date - 3
      Else
      Date_minus_one = Date - 1
  End If
  
  Set FS = CreateObject(&quot;Scripting.FileSystemObject&quot;)
  Set wb = ThisWorkbook
  ' Client_path = wb.Names(&quot;Path&quot;).RefersToRange.Value    ' use path as defined name on sheet
  Client_path = &quot;XXXXXXX &quot; &amp; Format(Date_minus_one, &quot;mmddyyyy&quot;) &amp; &quot;.xls&quot;
  
  
  If FS.fileexists(Client_path) Then
  
  ' Get only used part of column
  Set rngReconcile = wb.Sheets(1).Range(&quot;K:K&quot;)
  nRow = rngReconcile(rngReconcile.Cells.Count).End(xlUp).Row   ' Get last filled cell
  Set rngReconcile = Range(rngReconcile(1), rngReconcile(nRow)) ' Reduce rng size
  
  Set wbDirty = Workbooks.Open(Client_path)   ' Assumes it exists and is not open
  ' Get only used part of column
  Set rngWatch = wbDirty.Sheets(1).Range(&quot;A:A&quot;)
  nRow = rngWatch(rngWatch.Cells.Count).End(xlUp).Row     ' Get last filled cell
  Set rngWatch = Range(rngWatch(3), rngWatch(nRow))       ' Reduce range size
  
  Set rngNew = wb.Sheets(&quot;Client Watchlist&quot;).Range(&quot;K:K&quot;)
  brow = rngNew(rngNew.Cells.Count).End(xlUp).Row
  Set rngNew = Range(rngNew(2), rngNew(brow))
  rngNew.ClearContents
  
  Set rngNew = wb.Sheets(1).Range(&quot;K:K&quot;)(rngNew.Cells.Count).End(xlUp)(2)
  
  For Each c In rngWatch                   ' Each value in rngWatch
      On Error Resume Next                 ' Interrupt Error checking
      If IsError(WorksheetFunction.Match( _
          c.Value, rngReconcile, 0)) Then  ' If not in rngReconcile
          rngNew.FormulaR1C1 = c.Value     ' Copy to rngNew
          Set rngNew = rngNew(2)           ' Moves range down =Offset(rngNew,1,0)
      End If
      On Error GoTo 0                      ' Reset Error checking
      If (c.Row + 1) Mod 100 = 0 Then      ' Optional - Update user
          Application.StatusBar = &quot;Evaluating cell &quot; &amp; c(2).Address &amp; &quot;...&quot;
      End If
  Next c
  
  Application.StatusBar = False
  Application.DisplayStatusBar = oldStatusBar ' Reset Status Bar
  ActiveWindow.Close Savechanges:=False       ' Closes client email
  
  
  MsgBox (&quot;Reconcilied to &quot;) &amp; Client_path &amp; &quot; on &quot; &amp; Now
  
  Else
  
  MsgBox (&quot;Please save down &quot;) &amp; Client_path, vbCritical
  
  End If
  
  
  Call Prot
  
  Application.ScreenUpdating = True           ' Turn back on
  
  End Sub
  
  
  Public Function IsMonday(inputdate As Date) As Boolean
      Select Case Weekday(inputdate)
          Case vbMonday
              IsMonday = True
          Case Else
              IsMonday = False
      End Select
  End Function
  
  Sub manual_date()
  manual_date_input = InputBox(&quot;Enter Date (MMDDYYYY&quot;)
  
  
  End Sub
  </code></pre>
  <h3>Update</h3>
  <p>I added the following two sub procedures which shall pass the <code>dt</code> parameter as instructed below. I feel as if this variable <code>dt as date</code> is storing a value? I am able to run the sub procedure <code>Sub RunWithUserDate()</code> but the <code>Sub RunWithDefault()</code> procedure does not run smoothly. I have inserted several message boxes to view the value of <code>dt</code>. Should I be resetting the value of this date variable? If so, how could I? (Please note, I have cleaned up the code within the main sub procedure <code>Sub Client_Dirty_Recon()</code> and I have properly assigned the <code>dt</code> variable within the <code>client_path</code> variable.</p>
  <pre><code>Sub test2()
  MsgBox Date
  
  MsgBox dt
  
  MsgBox IsMonday(dt)
  IsMonday (dt)
  
  MsgBox (dt)
  
  End Sub
  Public Function IsMonday(inputdate As Date) As Boolean
      
      Select Case Weekday(inputdate)
          Case vbMonday
              dt = Date - 3               ' IsMonday = True
              'dt = Format(dt, &quot;mmddyyyy&quot;)
          Case Else
              dt = Date - 1
              'dt = Format(Date - 1, &quot;mmddyyyy&quot;)           ' IsMonday = False
              'dt = Format(dt, &quot;mmddyyyy&quot;)
      End Select
      
  End Function
  
  Sub RunWithDefault()                    ' Button 1: use current date
  'CHECK THIS AGAIN ***ALSO ADD PERMISSIONS IF NECESSARY
      MsgBox IsMonday(dt)
      MsgBox dt
      
      Client_Dirty_Recon IsMonday(dt)
      
  
  End Sub
                                          ' Button 2: get date from user
  Sub RunWithUserDate()                   ' Get dt value from user
  'PROMPT USER FOR PASSWORD
  
      dt = Application.InputBox(&quot;Enter Date (MM/DD/YYYY)&quot;, &quot;Manual Override&quot;)
      'du = Format(du, &quot;mmddyyyy&quot;)
      
      'du = Format(Application.InputBox(&quot;Enter Date (MM/DD/YYYY)&quot;), &quot;mmddyyyy&quot;)
  
      'dt = Format(dt, &quot;mmddyyyy&quot;)
  'MsgBox dt
          Client_Dirty_Recon dt
       'dt = Date
       
      
  End Sub
  </code></pre>