title: Declaring an active workbook variable Excel Vba
body: <p>(Excel VBA)</p>
  
  <p>How would i declare an active workbook variable. or a workbook variable in general.</p>
  
  <p>I have a program flipping back and forth between 2 excel workbooks, and currently we have it just reopen that workbook. But can I just declare it as a variable so i can reference it without re-opening. It would make my life a lot easier .</p>
  
  <p>Thanks in advance!</p>
  
  <p>My current example:</p>
  
  <pre><code>Dim xlsMatrixUp As String
  fileToOpen = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
  xlsMatrixUp = fileToOpen
  Workbooks.Open xlsMatrixUp
  ActiveWorkbook.Worksheets(4).Activate 'Grabs matrix file
  
  'Goes back to sheet with macro
  ThisWorkbook.Worksheets(4).Activate
      ActiveSheet.range("A1").Interior.Color = RGB(128, 128, 128)
  'This is off a working if statement 
  Workbooks.Open xlsMatrixUp
  ActiveWorkbook.Worksheets(4).Activate`
  'Returns to matrix and repeats. Any suggestions?
  </code></pre>