+ Reply to Thread
Results 1 to 2 of 2

How to Loop Macro

  1. #1
    Registered User
    Join Date
    05-23-2012
    Location
    Arlington, VA
    MS-Off Ver
    Excel 2007
    Posts
    2

    How to Loop Macro

    I've created a calculator in excel using some basic formulas. The calculator depends on several inputs. I've created a list of different combinations of inputs and I want to make a macro that will update the appropriate cells in the calculator, copy the result, and paste the value next to the combination of inputs. The thing is I only know how to record a macro, the code below does what I want for one row of inputs:

    Sub Test()
    '
    ' Test Macro
    '
    ' Keyboard Shortcut: Ctrl+t
    '
    Range("E25").Select
    ActiveCell.FormulaR1C1 = "=R[-19]C[82]"
    Range("E27").Select
    ActiveCell.FormulaR1C1 = "=R[-21]C[83]"
    Range("E33").Select
    ActiveCell.FormulaR1C1 = "=R[-27]C[84]"
    Range("E34").Select
    ActiveCell.FormulaR1C1 = "=R[-28]C[85]"
    Range("Q30").Select
    Selection.Copy
    Range("CM6").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Selection.NumberFormat = "$#,##0.00"
    End Sub

    How do I edit it to do this for the first row then go to the second and do the same thing only the "ActiveCell.FormulaR1C1 " should be based on the inputs in the new row? Does that question make sense, seems like it should be easy for someone with the know how. Thanks!

  2. #2
    Forum Contributor
    Join Date
    06-09-2011
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    194

    Re: How to Loop Macro

    Hi Cross1581,

    I am not sure if I really understood what the tool needs to do, but I give it a try. As I don't know where the loop shoud start, I allowed you to change both startrow as well as the endrow in the macro. If these assumptions are wrong, you might consider posting a sample of your file.

    Please Login or Register  to view this content.
    Regards
    Theo

    Don't forget to mark your threats as "solved" and provide feedback by clicking the star at the left

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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