
Originally Posted by
romperstomper
The code must also be in the same workbook to use the codename directly, or you must set a reference to the target workbook from the code workbook. You can also loop through all the sheets and check the codename form another workbook.
Thanks reomperstomper, that is the issue then, im referencing a workbook that i require the codename from, is it achievable then? This is my full code.
Dim rngeDestination As Range, rngeSource As Range
Dim i As Long
Set rngeDestination = ThisWorkbook.Worksheets("Data").Range("C" & Rows.Count).End(xlUp).Offset(1)
Workbooks.Open Filename:= _
"G:\Report Sept15.xlsx"
fname = ActiveWorkbook.Name
With Workbooks(fname). Worksheets("report1442310827144")
Set rngeSource = .Range("B19", .Range("D" & Rows.Count).End(xlUp).Offset(-12))
End With
rngeDestination.Resize(rngeSource.Rows.Count, 3).Value = rngeSource.Value
rngeDestination.Offset(, -1).Resize(rngeSource.Rows.Count).Value = Application.Max(rngeDestination.Parent.Range("B:B")) + 1
Workbooks("Report Sept15.xlsx").Activate
ActiveWindow.Close False
End Sub
Bookmarks