+ Reply to Thread
Results 1 to 4 of 4

Make a recorded macro generic

  1. #1
    Registered User
    Join Date
    04-16-2015
    Location
    Copenhagen
    MS-Off Ver
    2013
    Posts
    2

    Make a recorded macro generic

    So, Im relatively new in this macro stuff.

    Ive recorded a macro, but how do I make it generic? Right now I have to constantly change and add inputs for it to continue my calculation. I just need it to jump to a cell, deduct a number and then head to another cell.

    This is my inital recording

    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
    Range("G363").Select
    ActiveCell.FormulaR1C1 = "=R[10]C[-6]-R[9]C[-6]"
    Range("G364").Select
    ActiveCell.FormulaR1C1 = "=R[11]C[-6]-R[10]C[-6]"
    Range("G365").Select
    ActiveCell.FormulaR1C1 = "=R[12]C[-6]-R[11]C[-6]"
    Range("G366").Select
    ActiveCell.FormulaR1C1 = "=R[13]C[-6]-R[12]C[-6]"
    Range("G367").Select
    ActiveCell.FormulaR1C1 = "=R[14]C[-6]-R[13]C[-6]"
    Range("G368").Select
    ActiveCell.FormulaR1C1 = "=R[15]C[-6]-R[14]C[-6]"
    Range("G369").Select
    ActiveCell.FormulaR1C1 = "=R[16]C[-6]-R[15]C[-6]"
    Range("G370").Select
    ActiveCell.FormulaR1C1 = "=R[17]C[-6]-R[16]C[-6]"
    Range("G371").Select
    ActiveCell.FormulaR1C1 = "=R[18]C[-6]-R[17]C[-6]"
    Range("G372").Select
    ActiveCell.FormulaR1C1 = "=R[19]C[-6]-R[18]C[-6]"
    Range("G373").Select
    ActiveCell.FormulaR1C1 = "=R[20]C[-6]-R[19]C[-6]"
    Range("G374").Select
    ActiveCell.FormulaR1C1 = "=R[21]C[-6]-R[20]C[-6]"
    End Sub


    Thanks in advance

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Make a recorded macro generic

    Please attach you sample workbook
    Cheers!
    Deep Dave

  3. #3
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: Make a recorded macro generic

    You can use this. Select all the cells you want the formula to go into and then run the macro. As you know part of the formula looks at the column 6 columns to the left of where the formula will be. If you select any cells in columns A-F you will get undesirable results for that reason, there aren't 6 columns to the left of those columns, so the formula will look at the cells at the far right of the worksheet.

    Good Luck!!!


    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    04-16-2015
    Location
    Copenhagen
    MS-Off Ver
    2013
    Posts
    2

    Re: Make a recorded macro generic

    Thanks a lot, it worked!

+ 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. Recorded Macro is picking up specfic directory information. Need it more generic
    By bdicarlo1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-30-2013, 07:18 PM
  2. [SOLVED] Recorded Pivot Table Macro Doesn't Do What I Recorded!
    By diakonos1984 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2013, 11:01 AM
  3. Make recorded macro loop
    By cowannbell in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 01-11-2013, 09:53 AM
  4. [SOLVED] Trying to make a recorded macro work properly
    By Nick12 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-05-2012, 11:56 AM
  5. How do I change a recorded macro to make it general?
    By excelVBAn00b in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2012, 03:38 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