shane_aldrich
Board Regular
- Joined
- Oct 23, 2009
- Messages
- 148
I have two workbooks open. After my active workbook shift 11 columns to the sheet "Import", I'm trying to move a copy of the import sheet to another workbook that's already opened named RYG_Raw. I'm not really sure where the problem is, but my code gets hung up when I try to set wb2
Sub Raw_Sales()
'*************************
'*** Declare Variables ***
'*************************
Dim t1 As Date
Dim sFileName As String
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim rng1 As Range
'*********************
'*** Set Variables ***
'*********************
t1 = Now
sFileName = "RYG_Raw"
Set wb1 = ThisWorkbook
Set wb2 = sFileName & "_" & Format(t1, "YYYY_MM_DD") & ".xls"
Set ws1 = Sheets("Sales_Compile")
Set ws2 = Sheets("Import")
Set rng1 = ws1.Range(ws1.Columns(1), ws1.Columns(11))
'***************
'*** Execute ***
'***************
rng1.Copy Destination:=ws2.Cells(1)
ws2.Copy After:=wb2.Sheets(wb2.Sheets.Count)
wb1.Activate
End Sub
Sub Raw_Sales()
'*************************
'*** Declare Variables ***
'*************************
Dim t1 As Date
Dim sFileName As String
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim rng1 As Range
'*********************
'*** Set Variables ***
'*********************
t1 = Now
sFileName = "RYG_Raw"
Set wb1 = ThisWorkbook
Set wb2 = sFileName & "_" & Format(t1, "YYYY_MM_DD") & ".xls"
Set ws1 = Sheets("Sales_Compile")
Set ws2 = Sheets("Import")
Set rng1 = ws1.Range(ws1.Columns(1), ws1.Columns(11))
'***************
'*** Execute ***
'***************
rng1.Copy Destination:=ws2.Cells(1)
ws2.Copy After:=wb2.Sheets(wb2.Sheets.Count)
wb1.Activate
End Sub