Linearly Extrapolate between values in column

Prevost

Board Regular
Joined
Jan 23, 2014
Messages
198
Hi There. So I have my Supply and Return water temperatures and I am trying to calculate heat output using those. However, the temperature values do not have any decimal points which is an issue. What I want to do is basically linearly extrapolate to obtain temperature values with decimal points. I would like to do this by checking the cells to see if the next cell is higher, lower or the same and then act accordingly. It should keep going until it reaches a cell that is either higher or lower, count the number of cells that contain the same temperature value and then divide the temperature differential between the two cells (usually 1 degree) by the number of cells and either add or subtract that amount to each of the cells so that is is incrementally getting higher or lower towards the next temperature. It would change the PHW SWT (C) and the PHW RWT (C) columns appropriately. Any ideas?
Thanks in advance!

wiu1zt.png
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Here's what I have so far, the problem is that when there are more than one cell of the same value, they all change to the same value (which is only correct for the second cell in the range of cells that are equal)

Code:
Sub ChangeTemperatures()

    Dim SWT As Range
    Set SWT = Sheets("PHW Boiler").Range(Cells(2, 6), Cells(10, 6))

    Dim TempValue As Double
    Dim NewValue As Double
    
    Dim i As Long
    Dim BaseRow As Long
    Dim AddRows As Long
    Dim RowDifference As Long
    Dim Multiplier As Double
    Dim Counter
    
    BaseRow = 2
    AddRows = 1
    
        Do While BaseRow <= 10
        
            Do While Cells(BaseRow, 6) = Cells(BaseRow + AddRows, 6)
                AddRows = AddRows + 1
            Loop
            
            If AddRows <> 1 Then
                For i = (BaseRow + 1) To (BaseRow + AddRows - 1)
                    TempValue = Cells(i, 6)
                    NewValue = TempValue + ((Cells(BaseRow + AddRows, 6) - Cells(BaseRow, 6)) / AddRows)
                    Cells(i, 6) = NewValue
                Next i
            End If
            
            BaseRow = BaseRow + AddRows
            AddRows = 1
            
        Loop
           
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top