Hi this is my first ever post... quite new to this coding lark
coding up Excel 2007 and I'm having problems with this error. Firs time it works, second time it fails, third time it works, fourth time it fails... see the pattern! Trying to copy from one workbook to another then move to next clear line and paste next value
Can find a way round it anyone help PLEASE
Private Sub OpenOneFile()
Dim fn As Variant
Dim LR As Long
Dim n As Long
n1 = 0
n = 0
fn = Application.GetOpenFilename("Excel-files,*.xlsx", _
1, "Select One File To Open", , False)
'If TypeName(fn) = "Boolean" Then Exit Sub
' the user didn't select a file
Debug.Print "Selected file: " & fn
Workbooks.Open fn
'Sync Windows
Windows.CompareSideBySideWith "MASTER.xlsm"
Windows.SyncScrollingSideBySide = False
'----------------------------------------------------------------------------------
Windows("RFI_Template.xlsx").Activate
Range("M6").Copy
Windows("MASTER.xlsm").Activate
Sheets("RFI Log").Select
'Unprotect
ActiveSheet.Unprotect Password:="window"
n1 = Range("H3").Value
n = 6 + n1
Cells(n, 2).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False (FAILS HERE EVERY 2nd ATTEMPT)
'----------------------------------------------------------------------------------
Windows("RFI_Template.xlsx").Activate
Range("M7").Copy
Windows("MASTER.xlsm").Activate
Cells(n, 3).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'----------------------------------------------------------------------------------
Windows("RFI_Template.xlsx").Activate
Range("m10").Copy
Windows("MASTER.xlsm").Activate
Cells(n, 4).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'----------------------------------------------------------------------------------
Windows("RFI_Template.xlsx").Activate
Range("d12").Copy
Windows("MASTER.xlsm").Activate
Cells(n, 6).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'----------------------------------------------------------------------------------
Windows("RFI_Template.xlsx").Activate
Range("b16").Copy
Windows("MASTER.xlsm").Activate
Cells(n, 8).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'----------------------------------------------------------------------------------
Range("F2").Copy
Cells(n, 7).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
'----------------------------------------------------------------------------------
n1 = 0
n = 0
'Range("p1") = 0
'Close RFI_Template window
Windows("RFI_Template.xlsx").Activate
ActiveWorkbook.Close False
Windows("MASTER.xlsm").Activate
Range("e6").Select
'Protect Sheet
Windows("MASTER.xlsm").Activate
Sheets("RFI Log").Select
ActiveSheet.Protect Password:="window", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
End Sub
Bookmarks