Im having trouble sloting it in, it needs to go around the bold text, any advice?
Option Explicit
Sub Break_Report()
Dim wbTarget As Workbook 'workbook where the data is to be pasted
Dim wbThis As Workbook 'workbook from where the data is to copied
Dim strName As String 'target workbook
Dim cn As String
Dim shName As String
Dim wasOPEN As Boolean
shName = Range("D4").Value
Set wbThis = ActiveWorkbook 'set to the current active workbook (the source book)
On Error Resume Next
Set wbTarget = Workbooks("P:\Customer Contact Managers\MI_Resource_planning\A - DAILY\Lateness Trackers\Lateness 2014\Break Lateness.xlsm") 'try to find already open workbook
If Not wbTarget Is Nothing Then
wasOPEN = True 'make a note that it was already open
Else 'open it if it was closed, put your path in the space noted
Set wbTarget = Workbooks.Open("P:\Customer Contact Managers\MI_Resource_planning\A - DAILY\Lateness Trackers\Lateness 2014\Break Lateness.xlsm")
End If
wbTarget.Sheets(shName).Range("xfd1").EntireColumn.ClearContents 'select cell A1 on the target book
wbThis.Activate 'activate the source book
Application.CutCopyMode = False 'clear any thing on clipboard to maximize available memory
wbThis.ActiveSheet.Range("b2:k100").Copy 'copy the range from source book
'paste the data on the target book ( for just values PasteSpecial xlValues )
wbTarget.Sheets(shName).Cells(3, Columns.Count).End(xlToLeft).Offset(, 9).PasteSpecial xlPasteAll
Application.CutCopyMode = False 'clear any thing on clipboard to maximize available memory
If wasOPEN Then wbTarget.Save Else wbTarget.Close True 'save the target book, close it if it was closed before
wbThis.Close 'activate or close the source book again
Set wbTarget = Nothing 'clear memory
Set wbThis = Nothing
End Sub
Bookmarks