PDA

View Full Version : run time error 91 "object variable or with block variable not set



rohan8510
03-06-2015, 03:52 PM
hi,this code i have i am not able to figure out why it says run time error 91 "object variable or with block variable not set" could you please take a look,
the error pops at third line, when i close all the workbooks and open only the workbook which has this code it works fine,
i have tried to add "Dim rngcopy As Object" but it did not work, i am not able to figure out Dim rngcopy As ???

many thanks





Dim rngcopy As ?????
Windows("CNAV.xlsm").Activate
Set rngcopy = Sheets("Raw data").Range("A1:IV1").Find("Accrual excl XD+3", LookIn:=xlValues)
Set rngcopy = Range(rngcopy.Offset(1, 0), Cells(Rows.Count, rngcopy.Column).End(xlUp))
Set rngPaste = Workbooks("DummyIACB.xlsm").Sheets("Sheet1").Range("l2")
rngcopy.Copy
rngPaste.PasteSpecial xlPasteValues
rngPaste.PasteSpecial xlPasteFormats

Paul_Hossler
03-06-2015, 05:25 PM
One easy thing to try, assuming that all the sheets and workbooks are really there




Dim rngcopy As Range, rngPaste As Range