PDA

View Full Version : Solved: Pop up errors/boxes when running macro



ksquirt
01-22-2009, 02:00 PM
Ok, let's see if I can explain this properly the first time. I just wrote/recorded a macro to open a template, select a sheet, copy all of it and paste it onto the workbook I had open previously. There are two boxes that pop up that I have to select Yes and No to. How do I incorporate those into the macro? Here's the macro (Lucas, don't yell at me! I wanted to make sure it worked before I removed all the 'selects'!!)

Sub CopyLast()


'Opens workbook
Workbooks.Open Filename:="C:\Documents and Settings\n893581x\Desktop\2008-2012 HCFTG PMO Forecast Template_v.10.xls"

ActiveWorkbook.Sheets("Last").Select
Cells.Select
Selection.copy
ActiveWindow.ActivatePrevious
ActiveWorkbook.Sheets("Last").Select
Cells.Select
Selection.PasteSpecial

ActiveWindow.ActivatePrevious
ActiveWorkbook.Close



End Sub


The first 'error' says "A formula or sheet you want to move or copy contains the name 'Year' etc." I just want to click "yes" on this.

The second one says "There is a large amount of info on the Clipboard etc" I just want to click "no". There may be another way around that one too.

Bob Phillips
01-22-2009, 02:15 PM
Sub CopyLast()

Application.DisplayAlerts = False

'Opens workbook
Workbooks.Open Filename:="C:\Documents and Settings\n893581x\Desktop\2008-2012 HCFTG PMO Forecast Template_v.10.xls"

ActiveWorkbook.Sheets("Last").Cells.Copy
ActiveWindow.ActivatePrevious
ActiveWorkbook.Sheets("Last").Select
Cells.PasteSpecial

ActiveWindow.ActivatePrevious
ActiveWorkbook.Close

Application.DisplayAlerts = True
End Sub

ksquirt
01-22-2009, 02:21 PM
Beautiful!!! Thanks so much!