Results 1 to 2 of 2

Recorded Macro returns Run-time error '1004'

Threaded View

  1. #1
    Registered User
    Join Date
    12-28-2014
    Location
    Athens, Greece
    MS-Off Ver
    2010
    Posts
    6

    Recorded Macro returns Run-time error '1004'

    Hi,

    I recorded a macro to do the following:

    1. Delete Columns 'F' (Time) and 'G' (Room).
    2. Insert new 'G' column with the title 'Time 1'
    3. Insert new 'I' column with the title 'Time 2'
    4. Insert new row number 1
    5. Insert new row number 2
    6. Fit cells to contents (Select all cells and double click border)

    When I run the macro on a different sheet within the same workbook I get the following error

    Run-time error '1004':

    Method 'Range' of object'_Global' failed

    Here is the VBA script that excel created:

    Sub Macro3()
    '
    ' Macro3 Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+E
    '
        Columns("F:G").Select
        Selection.Delete Shift:=xlToLeft
        Columns("G:G").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Columns("I:I").Select
        Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
        Range("Table15[[#Headers],[Column1]]").Select
        ActiveCell.FormulaR1C1 = "Time 1"
        Range("Table15[[#Headers],[Column2]]").Select
        ActiveCell.FormulaR1C1 = "Time 2"
        Rows("1:1").Select
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        Cells.Select
        Cells.EntireColumn.AutoFit
        Range("A1").Select
    End Sub
    When I hit the 'Debug' button, it highlights

    Range("Table15[[#Headers],[Column1]]").Select
    Many thanks in advance and happy new year,
    absconditus

    PS I'm VBA-illiterate.
    Attached Files Attached Files
    Last edited by absconditus; 01-05-2015 at 05:02 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 10-20-2014, 05:33 PM
  2. [SOLVED] Sort Macro Run-time error '1004': Application/Object-defined error.
    By sam1212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2014, 10:05 AM
  3. Recorded pivot macro run time error 5
    By cindywylie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-18-2014, 08:38 PM
  4. Excel Macro Error - Run time error 1004 - Paste method of worksheet class failed
    By kvflynn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2012, 10:51 AM
  5. VBA Code for IF Statement returns Run-Time Error 1004
    By esphero in forum Excel General
    Replies: 3
    Last Post: 03-22-2012, 07:06 AM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1