Results 1 to 4 of 4

Get Run-Time Error 1004 With Simple Macro

Threaded View

  1. #1
    Registered User
    Join Date
    04-22-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    15

    Get Run-Time Error 1004 With Simple Macro

    I first saw an Excel spreadsheet three days ago, so this is a real beginner's question. I recorded a simple macro to select data from five (non-consecutive) cells in a row in one workbook, enter the data in the appropriate place in a second workbook, and then colour the source cells in the first workbook yellow as a reference. That all works well. But when I try to have the macro move down to the next row in the first workbook containing data that I want before it (the macro) ends, so that I don't have to use the mouse at all and can just keep hitting the keyboard command, I get run-time error 1004. So, most of all I'd like to know how to make this macro work. I'd also appreciate advice, though it's less critical, on how to make the macro loop through the process X times for X rows, so that the whole process would only take one keyboard command. That would be very satisfying.

    Thanks in advance, and this is the VBA code for the macro with the extra step that doesn't work:

    Sub Macro4()
    '
    ' Macro4 Macro
    '
    ' Keyboard Shortcut: Ctrl+f
    '
        ActiveCell.Offset(26, -4).Range("A1,C1,E1").Select
        ActiveCell.Offset(26, 0).Range("A1").Activate
        ActiveWindow.ScrollColumn = 2
        ActiveWindow.ScrollColumn = 3
        ActiveWindow.ScrollColumn = 4
        ActiveCell.Offset(0, -4).Range("A1,C1,E1,G1,I1").Select
        ActiveCell.Offset(0, 4).Range("A1").Activate
        Selection.Copy
        Windows("Target EXPERIMENTAL.xlsx").Activate
        ActiveSheet.Paste
        ActiveCell.Offset(1, 0).Range("A1").Select
        Windows("Source EXPERIMENTAL.xls").Activate
        Application.CutCopyMode = False
        With Selection.Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 65535
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
        ActiveWindow.SmallScroll Down:=3
        ActiveWindow.ScrollColumn = 3
        ActiveWindow.ScrollColumn = 2
        ActiveWindow.ScrollColumn = 1
        ActiveWindow.SmallScroll Down:=21
        ActiveCell.Offset(27, -8).Range("A1").Select
    End Sub
    Last edited by Paul; 04-22-2012 at 07:43 AM. Reason: Added CODE tags for new user. Please do so yourself in the future.

Thread Information

Users Browsing this Thread

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

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