Macro - Run Time Error '1004'


Posted by Renee' on August 15, 2001 5:47 AM

We are working on an existing file with Macros that someone else has set up. We are trying to add information to the file and when we try to run a Macro, we are getting the following error "Run Time Error '1004' PasteSpecial method of Range class failed". When we choose 'debug', it goes to the following line in the Macro:

Selection.PasteSpecial Paste:=x1Values, Operation:=x1Add, SkipBlanks:= _ True, Transpose:=False

We are just learning about Macros and I'm not sure how to figure out what it doesn't like here. Any advice would be helpful! THANKS!!!!!!!!!

Posted by Barrie Davidson on August 15, 2001 8:12 AM

Can you post the entire code?

Barrie

Posted by Renee' on August 16, 2001 10:33 AM

****************************
Here's the entire code...

Application.Goto Reference:="R1C2"
Columns("B:B").Select
Selection.Copy
Workbooks.Open FileName:= _
"\\filename is listed here"
Application.Goto Reference:="R1C2"
Selection.PasteSpecial Paste:=xlValues, Operation:=xlAdd, SkipBlanks:= _
True, Transpose:=False
Application.CutCopyMode = False
Calculate
Range("B3").Select
ActiveCell.FormulaR1C1 = "4103"
ActiveWindow.LargeScroll Down:=1
Range("B26").Select
ActiveCell.FormulaR1C1 = "6106"
ActiveWindow.LargeScroll Down:=1
Range("B49").Select
ActiveCell.FormulaR1C1 = "4130"
ActiveWindow.LargeScroll Down:=1
Range("B72").Select
ActiveCell.FormulaR1C1 = "131"
ActiveWindow.LargeScroll Down:=1
Range("B95").Select
ActiveCell.FormulaR1C1 = "134"
ActiveWindow.LargeScroll Down:=1
Range("B118").Select
ActiveCell.FormulaR1C1 = "4135"
ActiveWindow.LargeScroll Down:=1
Range("B141").Select
ActiveCell.FormulaR1C1 = "6317"
ActiveWindow.LargeScroll Down:=1
Range("B164").Select
ActiveCell.FormulaR1C1 = "8138"
Range("B165").Select
Application.Goto Reference:="R1C2"
Application.Goto Reference:="R1C1"
ActiveWorkbook.Save
End Sub

Posted by Barrie Davidson on August 16, 2001 1:58 PM

Renee, you are getting the error because Excel is trying to paste something when nothing has been selected to copy. This macro is trying to copy column B of whatever workbook is active (i.e., in the window. Hidden workbooks are not active) and paste it into a file named "\\filename is listed here". Are you running this macro with no workbooks in the active window and do you really want the macro to open a file named that?

Barrie



Posted by Renee' on August 20, 2001 12:07 PM

Hey Barrie! Thanks so much for your input. We got it to work! I believe what was happening, we had the file open that the macro was trying to open and we were getting an error. Appreciate your help!! Renee'