Create VBA to fill in blank cells between two values with even values

  • Good morning all,


    I am VERY green with VBA and the syntax to do what i am trying is so far beyond my understanding, i don't even know how to approach it. I found some VBA threads on ozgrid that do something similar to what i need, but they were all just a +1 to the first value. I was hoping someone could shed some light on the situation below.


    I am transcribing awkward graphs into data sets, where the graphs do not have even X and Y values, so only portions of the graph are evenly distributed. In the portions of the graph that are even, i am able to get the first and last value, and then move onto the next even section of the graph. Between those two values, the line in the graph would produce even values in between the first and last values.


    What i have been doing is using formulas to take those two values, find the difference, dividing it by the number of blanks in between, then copying the result and pasting the values into the blanks in my table. This works great, but is very time consuming.


    For example, one of the ranges in my column is 13 cells. The value of the first cell is 1.360 and the value of the last cell is 1.850. The difference between them is 0.490 and when you divide that by 12, there is a 0.041 (rounded to 0.000) increment to evenly get from the first to the last value.


    The images below shows the range described above with the blank cells:



    This image shows the same range after doing the math and filling it in with even 0.041 distribution.



    The end result i would like, would be to select a range (varying from 3 to 150 cells, always in one single column) that has a value in the first and the last cell with blanks in between. A macro button would run the VBA code, do the math and evenly fill in the blanks in between.


    Thank you in advance for any tips on how to speed this process up :)

  • Try:

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Try:

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.