+ Reply to Thread
Results 1 to 3 of 3

Editing my recorded macro to get it to work despite a range length change

  1. #1
    Registered User
    Join Date
    08-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Question Editing my recorded macro to get it to work despite a range length change

    Please look at my recorded macro below and tell me how I can change the lines 13 to 15 to be able use the macro even though the range length is different.
    Thanks for your help.



    1 Windows("JODA - Open AMR Service Requests.xlsx").Activate
    2 Sheets("All").Select
    3 Range("K2").Select
    4 ActiveCell.FormulaR1C1 = "=TODAY()-RC[-3]"
    5 Range("O2").Select
    6 ActiveCell.FormulaR1C1 = "=RC[4]"
    7 Range("P2").Select
    8 ActiveCell.FormulaR1C1 = "=RC[4]"
    9 Range("Q2").Select
    10 ActiveCell.FormulaR1C1 = "=RC[4]"
    11 Range("R2").Select
    12 ActiveCell.FormulaR1C1 = "=RC[4]"
    13 Range("K2:AA2").Select
    14 Selection.AutoFill Destination:=Range("K2:AA5313"), Type:=xlFillDefault
    15 Range("K2:AA5313").Select
    16 Columns("K:K").Select
    17 Selection.Copy
    18 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    19 :=False, Transpose:=False
    20 Range("O2:R2").Select
    21 Range(Selection, Selection.End(xlDown)).Select
    22 Application.CutCopyMode = False
    23 Selection.Copy
    24 Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    25 :=False, Transpose:=False
    26 Range("H2:I2").Select
    27 Range(Selection, Selection.End(xlDown)).Select
    28 Application.CutCopyMode = False
    29 ' Pause so you can inspect results...
    30 MsgBox "All done, click me to continue...", vbMsgBoxSetForeground
    31 Windows("Macro_SR.xlsm").Activate

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Editing my recorded macro to get it to work despite a range length change

    Welcome to the forum!

    Select is seldom needed.

    I guess you would just change the string? What governs or defines length?

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Editing my recorded macro to get it to work despite a range length change

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-14-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Editing my recorded macro to get it to work despite a range length change

    Kenneth,
    The range ("K2:AA5313") can change to ("K2:AA7000") or ("K2:AA8313"). Is there any code that will allow me to capture up to the last line?
    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Editing a recorded macro to be useable on future data sets
    By Jason210 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-25-2012, 01:09 PM
  2. Recorded Macro Does Not Work
    By TheColorLavender in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2012, 01:56 AM
  3. How to alter a recorded macro to work better
    By antonymiller in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2009, 02:53 AM
  4. [SOLVED] Excel macro, editing recorded cell.. not current
    By TroyT in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-12-2006, 09:30 AM
  5. [SOLVED] Editing recorded macro code. Referencing workbook name in functio
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-06-2005, 07:06 PM

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