Excel vba Pastespecial xlvalues

Hi,

I have been trying to write a small sub that will take contents from the clipboard to an excel spreadsheet...I have two Workbooks open...I select the data i want to copy...hit Ctrl C...then go to the other workbook which i want to paste the values.  On this sheet I have a button that runs the following macro...It worked earlier today but now every time i run it it hangs on the pastespecial line with the following error.  "Runtime Error '1004' Pastespecial method of range class failed.  I have tried every example i can find on the internet and nothing will work.  Any ideas?

Thanks
Sub ImportData()

Application.range("A12").select
ActiveCell.PasteSpecialxlPasteValues , xlPasteSpecialOperationNone

Open in new window

ToddHawley4984Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom UrtisCommented:
By chance is the destination worksheet protected, or are there any merged cells in association with A12.
0
jppintoCommented:
Change this:

ActiveCell.PasteSpecialxlPasteValues , xlPasteSpecialOperationNone

to this:

ActiveCell.PasteSpecial paste:=xlValues, operation:=xlPasteSpecialOperationNone

jppinto
0
ToddHawley4984Author Commented:
Tom_Urtis: No to both questions.

Jppinto:  Same result with your code..

This may be of help....after the code fails if i exit and try to manually pastespecial i get the dialog asking if i want to paste as HTML, Unicode Text, Text....If i try this before running to code i can pastespecial just fine....that help?
0
Tom UrtisCommented:
It sounds like you are attempting to copy data from a workbook in one instance of Excel, and pasting it into another instance of Excel.   You probably had both workbooks open in the same instance of Excel when this worked for you.   The question is why you need tow separate instances, or can you just use one, seeing as you have used only one before when it was working.   There is code to handle transfer of data between instances but you probably don't need to do that.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ToddHawley4984Author Commented:
I opened the two spreadsheets in separate instances and it works fine...thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.