Hi there,
The attached version of your routine appears to run correctly on my Office 2013 installation.
It uses the following code:
Option Explicit
'=========================================================================================
'=========================================================================================
Private Sub BlankVIT()
Const sBLANK_VIT_NAME As String = "\\ttcfile11\merchmfa\0_F Drive Re-Org\" & _
"13_Negotiations\01_Models\Merch OFM\" & _
"Merch OFM VIT.xlsb"
Const sCONTROL As String = "Control"
Const sLISTS As String = "DropDownLists"
Const sINFO As String = "Item Info"
Dim sRelativePath As String
Dim rSourceRange As Range
Dim rTargetCell As Range
Dim sMyFileName As String
Dim wbkBlankVIT As Workbook
Dim sEventName As String
Dim wksControl As Worksheet
Dim lErrorNo As Long
Application.ScreenUpdating = False
Set wksControl = ThisWorkbook.Worksheets(sCONTROL)
wksControl.Activate ' Not needed if the routine is called from this worksheet
Set wbkBlankVIT = Workbooks.Open(sBLANK_VIT_NAME)
Set rSourceRange = wksControl.Range("F7:H57")
Set rTargetCell = wbkBlankVIT.Sheets(sLISTS).Range("D4")
Call CopyData(rSourceRange:=rSourceRange, rTargetCell:=rTargetCell)
Set rSourceRange = wksControl.Range("K7:M57")
Set rTargetCell = wbkBlankVIT.Sheets(sLISTS).Range("G4")
Call CopyData(rSourceRange:=rSourceRange, rTargetCell:=rTargetCell)
Set rSourceRange = wksControl.Range("Z10:Z12")
Set rTargetCell = wbkBlankVIT.Sheets(sINFO).Range("J7")
Call CopyData(rSourceRange:=rSourceRange, rTargetCell:=rTargetCell)
sEventName = wksControl.Range("Event_Name").Value
sMyFileName = sEventName & " - Blank VIT.xlsb"
sRelativePath = ThisWorkbook.path & "\" & sMyFileName
On Error Resume Next
wbkBlankVIT.SaveAs Filename:=sRelativePath, FileFormat:=xlExcel12
lErrorNo = Err.Number
On Error GoTo 0
If lErrorNo <> 0 Then
MsgBox "The new workbook has NOT been saved", vbExclamation
End If
wbkBlankVIT.Close SaveChanges:=False
wksControl.Range("Y14") = sRelativePath
Application.ScreenUpdating = True
End Sub
'=========================================================================================
'=========================================================================================
Private Sub CopyData(rSourceRange As Range, rTargetCell As Range)
Dim vaDataValues As Variant
Dim iNoOfColumns As Integer
Dim rTargetRange As Range
Dim iNoOfRows As Integer
vaDataValues = rSourceRange.Value
iNoOfColumns = UBound(vaDataValues, 2)
iNoOfRows = UBound(vaDataValues, 1)
With rTargetCell
Set rTargetRange = Range(rTargetCell.Cells(1, 1), _
rTargetCell.Cells(iNoOfRows, iNoOfColumns))
End With
rTargetRange.Value = vaDataValues
End Sub
Hope this helps - please let me know how you get on.
Regards,
Greg M
Bookmarks