My code below is giving me a problem. The first line works, to open the workbook. My second line, the "Set" line, gives me an error cod 424, "Object Required". I think (maybe) it's becuase the workbook newly opened isn't the active workbook, so how do I resolve this? As you can see, I just want it open long enough to copy one sheet from it. Any help is greatly appreciated.
Thanks,
JohnWorkbooks.Open ("\\12AUST1001FS01\SHARE10011\Budget\SOBUDGET\11MFR\SO_Projections\" & MO & "\" & MO & "_AgyProjections_PivotsforAnalysis.xls"), ReadOnly:=True, UpdateLinks:=True Set PivAnal = Active.Workbook With PivAnal .Sheets(Array("Play")).Copy _ Before:=Workbooks("2BDeleted.xls").Sheets("Lookups") End With PivAnal.Close False
Last edited by jomili; 05-17-2011 at 10:12 AM.
You can just do this:
Dim PivAnal As Workbook Set PivAnal = Workbooks.Open("\\12AUST1001FS01\SHARE10011\Budget\SOBUDGET\11MFR\SO_Projections\" & _ MO & "\" & MO & "_AgyProjections_PivotsforAnalysis.xls", ReadOnly:=True, UpdateLinks:=True)
Dom
"May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."
Use code tags when posting your VBA code: [code] Your code here [/code]
Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.
Thanks Dom,
That's certainly more elegant than the way I was working toward. I had a little trouble at first (parenthesis in the wrong place, my error) but very quickly got that straitened out and the code worked like a champ. I'll use this routine over and over again. Thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks