Results 1 to 5 of 5

Thread: [Excel] Macro Mixing Relative and Fixed References

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2012
    Posts
    6

    [Excel] Macro Mixing Relative and Fixed References

    Hi again everyone,

    Sorry to have so many questions!

    I'm trying to create my first macro but I need it to have both relative and fixed references. Basically what I need is:

    1. Copy value from a location that moves down a list one item at a time.
    2. Paste this value into the same cell every time.
    3. Copy a second value from a different location that never changes.
    4. Paste this second value into a location that moves down a list one item at a time.

    I made a diagram that sort of shows what I mean...




    So to accomplish this I tried creating two macros, one that was with fixed references and one with relative references, and splicing them together to get the following:

    Sub Copy1()
    '
    ' Copy1 Macro
    '

    '
    ActiveCell.Offset(-4, -1).Range("A1").Select
    Selection.Copy
    Range("C2").Select
    ActiveSheet.Paste
    Range("H20:I20").Select
    Application.CutCopyMode = False
    Selection.Copy
    ActiveCell.Offset(-18, 3).Range("A1:B1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End Sub


    But not surprisingly I got an error: "Run-time error '1004': Application-defined or object-defined error." When I click debug, it highlights the line ActiveCell.Offset(-4, -1).Range("A1").Select in yellow.

    Can anyone help? I would appreciate it very much.

    Thank you!
    Attached Images Attached Images  
    Last edited by tcss; May 25th, 2012 at 11:03 AM. Reason: More info

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width