Results 1 to 3 of 3

Thread: Runtime Error 1004 in vba excel

  1. #1
    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

  2. #2
    Join Date
    May 2008
    Posts
    4,345

    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

  3. #3
    Join Date
    May 2008
    Posts
    4,570

    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.

Similar Threads

  1. Replies: 1
    Last Post: 14-03-2012, 01:08 PM
  2. Excel 2007 Macro runtime error '1004'
    By JRadimus in forum Windows Software
    Replies: 1
    Last Post: 14-01-2012, 12:19 AM
  3. Runtime error R6025 on Excel 2010 with Windows 7
    By Maal-Gaadi in forum Windows Software
    Replies: 5
    Last Post: 05-10-2011, 10:31 AM
  4. Replies: 3
    Last Post: 22-04-2009, 11:02 PM
  5. Microsoft Visual C++ Runtime Library Symantec Runtime error
    By Ranchero in forum Windows XP Support
    Replies: 8
    Last Post: 27-09-2008, 09:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,649,410.66010 seconds with 17 queries