+ Reply to Thread
Results 1 to 14 of 14

Looping list of points through function to give answers

  1. #1
    Registered User
    Join Date
    05-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    79

    Question Looping list of points through function to give answers

    Hi All,

    I have a list of numbers in Column E. In cell B2 I need to input the numbers from this list which will give me a corresponding answer in cell C12. I need to then paste this answer next to its original value, say in Column F. I need to then get the macro to loop this function through the entire length of the list in Column E. This list may change in length as well so I would need to have the macro determine the end for itself.

    I am very much an amateur so any help would be greatly appreciated.

    Thankyou in advance,

    Spicey

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Looping list of points through function to give answers

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  3. #3
    Registered User
    Join Date
    05-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    79

    Re: Looping list of points through function to give answers

    Ok davesexcel, I have attached a very simple sample of what needs to happen. I thought it was simple enough not to have to attach.

    In this instance, column E will have my raw data. I need to put each number into the input cell (B2) , highlighted in yellow. I then need to copy the answer this gives from the output cell (C12) into column F alongside the original input value. Obviously i have just made up some small function in this instance for illustration purposes but the real thing is much more detailed and no I cannot use functions in my macro to do it. I just need the macro to go through my raw data one at a time and copy and paste the values and then move down to the next row. I have done the first few as an example.

    In my real spreadsheet I will have a list anywhere from 200 odd points to possibly thousands and thus I also need the macro to determine when the raw data finishes and not continue on. Hope this makes sense. I have got as far as recording the cut and paste parts for my macro but I dont know how to make this work in a loop like I have explained.

    VBA_ListCalculatorFunction.xlsx

    Any help is appreciated!

    Cheers,

    Spicey

  4. #4
    Registered User
    Join Date
    05-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    79

    Question Re: Looping list of points through function to give answers

    This is what I have come up with so far but obviously doesnt work. I get an overflow error when trying to determine the Answer.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Looping list of points through function to give answers

    You don't need VBA for this.

    In the example below, the formula in B2 stands in for your arbitarily-cnmplicated calculation chain. Note the formula in B4.

    Select A4:B12, Data > What If Analysis, Column input cell: A2

    That's it.

    Row\Col
    A
    B
    C
    1
    Input
    Output
    2
    26.998
    528.892
    B2: =A2^2 - 200
    3
    4
    Inputs
    528.892
    B4: =B2
    5
    29.234
    654.627
    6
    29.456
    667.656
    7
    28.723
    625.011
    8
    26.998
    528.892
    9
    27.906
    578.745
    10
    27.253
    542.726
    11
    28.123
    590.903
    12
    29.717
    683.100
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    05-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    79

    Re: Looping list of points through function to give answers

    Shg, It appears you have not read my description properly. I have de-sensitised data so yes for this example I could do this without using macro... HOWEVER, for the actual spreadsheet I need to apply this to, I CANNOT! I must use a VBA. The spreadsheet contains multiple rows and collumns of calculations and adjustments to the Input value before giving the final output value. All this must stay as is with the formatting. THUS I require a simple macro to do the task that I have explained!

    Regards,

    Spicey

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Looping list of points through function to give answers

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    79

    Re: Looping list of points through function to give answers

    Does this not suggest using only the formula listed in C12?

    In my real sheet there are many formulas applied through previoius cells in the working section before the output is given in C12

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Looping list of points through function to give answers

    It uses the result in C12, by whatever tortuous path it arrived.

  10. #10
    Registered User
    Join Date
    05-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    79

    Lightbulb Re: Looping list of points through function to give answers

    Ok managed to solve this myself, Took far longer than i would have preferred and a lot of trial and error, but this is the code that I ended up developing for my final sheet. I had two collumns of data i had to copy into two inputs before copying out the two outputs. Obviously cell references are different from the example i used as this is from my actual workbook but the jist is the same. My two data columns where Q and R.

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    05-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    79

    Re: Looping list of points through function to give answers

    shg, If I was a bit more savvy I probably could simplify what i have greatly using your syntax.

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Looping list of points through function to give answers

    Did you try my suggestion?

  13. #13
    Registered User
    Join Date
    05-26-2013
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    79

    Re: Looping list of points through function to give answers

    No because I am not sure how to make this work as I actually have two columns of input data for my actual spread sheet and both numbers from these columns must be inputed into their respective cell prior to extracting both outputs. They cannot be done individually or one at a time as both inputs affect both outputs. Both outputs are then put into the 2 columns to the right of the original data.

    How would I make it complete the first part of the With command for both cells before extracting both outputs? In my actual sheet I have raw data (lat and long) in columns Q and R. The input cells for these are F4 and L4 respectively and the output cells E40 and K40 respectively. These results are then placed in columns S and T.

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Looping list of points through function to give answers

    Maybe post the actual problem ...
    Last edited by shg; 01-14-2015 at 01:46 AM.

+ 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. Replies: 1
    Last Post: 01-30-2014, 12:44 AM
  2. Replies: 1
    Last Post: 08-14-2010, 10:33 PM
  3. Looping through cells to give the same name
    By TryToExcel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2010, 07:29 AM
  4. Replies: 0
    Last Post: 01-10-2006, 10:28 AM
  5. [SOLVED] Is there a function to give us the highest value in a list of tex
    By Calaw in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-11-2005, 06:55 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