"End With" should be on one line.
But you still made other changes. You may want to copy from this post (some
wrap text formatting corrected).
Option Explicit
Private Declare Function SetCurrentDirectoryA Lib _
"kernel32" (ByVal lpPathName As String) As Long
Sub ChDirNet(szPath As String)
Dim lReturn As Long
lReturn = SetCurrentDirectoryA(szPath)
If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path."
End Sub
Sub ImportRetroBoxDailyFiles()
Dim Resp As Long
Dim networkPath As String
Dim MyFileName As Variant
Dim CurDriveFolder As String
Dim newWkbk As Workbook
Dim testRange As Range
networkPath = "\\HARDWARE\Requests\test_network_append\"
CurDriveFolder = CurDir
On Error Resume Next
ChDirNet networkPath
If Err.Number <> 0 Then
MsgBox "error changing folder"
Err.Clear
End If
On Error GoTo 0
MyFileName = Application.GetOpenFilename("Excel Files, *.xls")
If MyFileName = False Then
'do nothing, user hit cancel
Else
Set newWkbk = Workbooks.Open(Filename:=MyFileName)
Set testRange = Nothing
On Error Resume Next
Set testRange = newWkbk.Names("Pick_Ups").RefersToRange
On Error GoTo 0
If testRange Is Nothing Then
MsgBox "Pick_UPs wasn't found!"
Else
If testRange.Rows.Count < 2 Then
'if less then 2 rows, must be only headers , Ignore
MsgBox "Only Headers!" ' pop-up a box is only headers found
Else
With testRange
.Resize(.Rows.Count - 1, .Columns.Count).Offset(1, 0).Copy _
Destination:=ThisWorkbook.Worksheets("Import") _
.Range("B65536").End(xlUp).Offset(0, 0)
End With
End If
End If
End If
newWkbk.Close savechanges:=False
'thisworkbook.save '<---are you sure you want to save this workbook??
ChDirNet CurDriveFolder
End Sub
And this comment still stands:
But I still have heartburn over your .offset(0,0). I think you'll find that it
may be overwriting a cell with something in it.
I think I am a little bit lost: here is how the script looks exactly as
of now, I tried to change that area:
<<snipped>>