If you select a range on an inactive sheet, the error will occur.
In your case, I thing the code work fine if wsDrawings is active sheet and error if active sheet is another.
Maybe the following code will solve your problem.
With wsDrawings
LR1 = .Cells(.Rows.Count, 1).End(xlUp).Row
.Columns("O:O").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
.Range("O2").FormulaR1C1 = "=IF(ISBLANK(RC[-3]),RC[-1],RC[-3])"
.Range("O2").Copy
.Select
.Range("O2:" & "O" & CStr(LR1)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End With
Besides, you can paste without select destination range. Like this:
With wsDrawings
LR1 = .Cells(.Rows.Count, 1).End(xlUp).Row
.Columns("O:O").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
.Range("O2").FormulaR1C1 = "=IF(ISBLANK(RC[-3]),RC[-1],RC[-3])"
.Range("O2").Copy .Range("O2:" & "O" & CStr(LR1))
End With
Or set formula for all cells of range one time.
With wsDrawings
LR1 = .Cells(.Rows.Count, 1).End(xlUp).Row
.Columns("O:O").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
.Range("O2:" & "O" & CStr(LR1)) = "=IF(ISBLANK(RC[-3]),RC[-1],RC[-3])"
End With
Bookmarks