+ Reply to Thread
Results 1 to 6 of 6

VBA for repeating a calculation and pasting a value-only list of inputs/outputs

  1. #1
    Registered User
    Join Date
    05-24-2019
    Location
    Glasgow, UK
    MS-Off Ver
    365
    Posts
    4

    VBA for repeating a calculation and pasting a value-only list of inputs/outputs

    So I have a single input cell (say D1) and a single output cell (say D2). I would like to make a table of pasted values for a range of inputs/outputs in the range A1:B100.
    I'm guessing this would be something using a For...Next loop (For i = 1 to 100) but I'm totally new to VBA and don't know how to write the macro.
    Any help would be very much appreciated. I hope I've explained the problem well enough!
    Last edited by HanJam; 05-24-2019 at 09:20 AM.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA for repeating a calculation and pasting a value-only list of inputs/outputs

    Hi HanJam,

    Welcome to the forum

    It is possible a loop is the best approach, but that all depends on the logic of how the cells are populated. It would be ideal if you can provide a sample workbook, doesn't need real data, but it should represent the format/content of the real data.
    Provide before/after samples, and the logic behind it.

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: VBA for repeating a calculation and pasting a value-only list of inputs/outputs

    So, what you want to do is record values in D1 & D2 for each time value is entered in D1.

    Then out put to A1:B100 range?

    Then there is no need to do loop. You will just need to trigger the code each time value in D1 changes.

    Ex:
    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Registered User
    Join Date
    05-24-2019
    Location
    Glasgow, UK
    MS-Off Ver
    365
    Posts
    4

    Re: VBA for repeating a calculation and pasting a value-only list of inputs/outputs

    Yes, I do want to record values in D1 & D2 for each time value is entered in D1, and output the data to the A1:B100 range. I couldn't get your example macro to run in my worksheet however - do I need to do more than just past the code into a new module?

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: VBA for repeating a calculation and pasting a value-only list of inputs/outputs

    The code would not be in a normal module. In the vba editor, double-click the name of the sheet where the code should trigger, and put it in there.

    @CK76, nice job understanding the requirement

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: VBA for repeating a calculation and pasting a value-only list of inputs/outputs

    What Arkadi said

    But, note that code will start data entry at A2:B2. A1:B1 is reserved for headers.

    See attached sample.

+ 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. Cells that can be inputs or outputs
    By shawnamillion in forum Excel General
    Replies: 2
    Last Post: 02-11-2016, 11:58 PM
  2. [SOLVED] how to have multiple inputs and outputs?
    By Sticky_Frogg in forum Outlook Formatting & Functions
    Replies: 4
    Last Post: 07-22-2015, 12:51 PM
  3. [SOLVED] Getting different formula outputs for different given inputs
    By Jay Pee in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-12-2013, 04:19 AM
  4. IF with multiple inputs and outputs
    By zdej in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-20-2013, 05:52 PM
  5. Help with multiple inputs and outputs
    By FinanceGuy in forum Excel General
    Replies: 1
    Last Post: 04-28-2010, 10:04 PM
  6. Calculation on Last Inputs into a List
    By AccountantCost in forum Excel General
    Replies: 3
    Last Post: 10-17-2009, 03:36 AM
  7. Replies: 1
    Last Post: 05-11-2006, 08:10 AM

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