Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Runtime Error 1004 in vba excel

Windows Software


Reply
 
Thread Tools Search this Thread
  #1  
Old 17-03-2009
Member
 
Join Date: Jul 2006
Posts: 289
Runtime Error 1004 in vba excel
  

Hi,

I am trying to import data from an excel file to another using a macro.
The problem is When I paste the values I get the following error: "This operation requires that the cells combine with the same size" (error 1004 runtime)

The macro code is as follows, and the error is given by the line preceded by (*):

Code:
Workbooks.Open Filename: = "L: \ myFile.xls", _ 
UpdateLinks: = 0 
Sheets ( "tab02). Select 
Range ( "A4: T47"). Select 
Selection.Copy 
Windows (MyFile2.xls). Activate 
Sheets ( "Files"). Select 
Range ( "A4"). Select 
Selection.PasteSpecial Paste: = xlFormats, Operation: = xlNone, SkipBlanks: = _ 
False, Transpose: = False 
(*) Selection.PasteSpecial Paste: = xlValues, Operation: = xlNone, SkipBlanks: = _ 
False, Transpose: = False 
Columns ( "A: A"). EntireColumn.AutoFit
Thank you very much in advance.

__________________
Signatures reduce available bandwidth
Reply With Quote
  #2  
Old 17-03-2009
Member
 
Join Date: May 2008
Posts: 4,339
Re: Runtime Error 1004 in vba excel

You receive a "Runtime error 1004 , When you try to copy and to paste filtered data programmatically in a Microsoft Office Excel 2003 workbook, you receive one of the following error messages:

See here for more helps http://support.microsoft.com/kb/905164
Reply With Quote
  #3  
Old 17-03-2009
Member
 
Join Date: May 2008
Posts: 4,565
Re: Runtime Error 1004 in vba excel

Hello.
Try the following code:

Code:
Workbooks.Open Filename: = "c: \ myFile.xls" UpdateLinks: = 0 
Sheets ( "tab02). Select 
Worksheets ( "tab02). Range (" A4: K49 "). Select 
Selection.Copy 
Windows (MyFile2.xls). Activate 
Sheets ( "Files"). Select 
Worksheets ( "Files"). Range ( "A4"). Select 
Selection.PasteSpecial Paste: = xlFormats, Operation: = xlNone, SkipBlanks: = False, Transpose: = False 
Selection.PasteSpecial Paste: = xlValues, Operation: = xlNone, SkipBlanks: = False, Transpose: = False 
Columns ( "A: A"). EntireColumn.AutoFit
The key is to use:
Worksheets ( "tab02). Range (" A4: K49 "). Select

Instead of:
Range ( "A4: K49"). Select

Although it has been selected the sheet where you want to take the information during the execution of the VBA does not recognize it.

I hope this information serves you, but do not hesitate to ask again.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Runtime Error 1004 in vba excel"
Thread Thread Starter Forum Replies Last Post
Excel VBA Run-time error '1004' Paste method of Worksheet class failed PatrickW Windows Software 1 14-03-2012 02:08 PM
Excel 2007 Macro runtime error '1004' JRadimus Windows Software 1 14-01-2012 12:19 AM
Runtime error R6025 on Excel 2010 with Windows 7 Maal-Gaadi Windows Software 5 05-10-2011 11:31 AM
Using Internet Explorer gives Microsoft Visual C++ Runtime Library Runtime Error Abejar Windows Software 3 23-04-2009 12:02 AM
Microsoft Visual C++ Runtime Library Symantec Runtime error Ranchero Windows XP Support 8 27-09-2008 10:08 AM


All times are GMT +5.5. The time now is 10:49 AM.