Hi,
I have been updating a workbook by adding some new sheets and some code that only works on these sheets but the existing code to import the data no longer works. I have tried this code on a new workbook and it works fine, the errors that I have got so far are a Compile error and run time erro 438. Can anyone tell me why this is doing this?
here is the import code from the existing workbook, it is currently stopping on the red text.
I have been updating a workbook by adding some new sheets and some code that only works on these sheets but the existing code to import the data no longer works. I have tried this code on a new workbook and it works fine, the errors that I have got so far are a Compile error and run time erro 438. Can anyone tell me why this is doing this?
here is the import code from the existing workbook, it is currently stopping on the red text.
Rich (BB code):
Sub Import()
Dim Finfo As String
Dim Title As String
Dim FileName As Variant
Dim CurrentFile As Variant
Dim CurrentFileName As String
Dim NewFileName As String
'Import 71mm
Application.ScreenUpdating = False
Application.EnableEvents = False
Sheets("71mm").Select
CurrentFileName = ActiveWorkbook.Name
Title = "Select 71mm Profile"
FileName = Application.GetOpenFilename(Finfo, FilterIndex, Title)
If FileName = False Then
MsgBox "No file was selected."
Exit Sub
End If
Workbooks.Open FileName, ReadOnly:=1, UpdateLinks:=False
NewFileName = ActiveWorkbook.Name
Sheets("profiles").Select
Range("a1:n1809").Select
Selection.Copy
Workbooks(CurrentFileName).Activate 'Go back to the original file
Sheets("71mm").Select
Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False 'Paste the copied cells
Range("a1").Select
Workbooks(NewFileName).Activate 'Go back to the new file
Application.CutCopyMode = False
ActiveWorkbook.Close False 'close new file