jbenfleming
New Member
- Joined
- Mar 30, 2017
- Messages
- 34
I am trying to open up a workbook that is declared as a variable. Is there a way to do this by using the variable name? I'd rather not have to use the long file path name. In the code after I move "blanksheet" from "dailysales" to "monthly" the dailysales workbook will no longer be open, as "blanksheet" was the only sheet in that workbook. After moving that sheet over I want to open the dailysales workbook again.
Code:
Option Explicit
Sub adailsalesend()
Dim rownum As Double
Dim dailysales As Workbook
Dim monthly As Workbook
Dim blanksheet As Worksheet
Set dailysales = ActiveWorkbook
Set blanksheet = ActiveSheet
Workbooks.Open Filename:="filenamehere.xlsx"
Set monthly = ActiveWorkbook
dailysales.Activate
Columns("k:k").Delete
blanksheet.Move After:=monthly.Sheets(monthly.Sheets.Count)
'below this comment is where I want to open the "dailysales" book. The code does not work.
Workbooks.Open (dailysales)
End Sub