Results 1 to 9 of 9

Thread: Range of inputs and graphing of result

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Thank you for your reply and sorry for such a delay in getting back to you.

    This code works as desired for that purpose.

     Sub test()    
    Dim V As Double
    lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    inarr = Range(Cells(1, 1), Cells(lastrow, 3))
    For i = 2 To lastrow
        V = inarr(i, 3)
        Cells(i, 7) = X(V)
    Next i
    Worksheets(1).Range("G1").Value = "dP / L"
    End Sub
     
     
    Function X(V As Double) As Double
     X = V * Worksheets(1).Range("E2") / Worksheets(1).Range("D2")
    End Function       'Here the constant values are brought from the worksheet, whilst the variable input is still accounted for.

    For a similar situation, but for one where there is only one variable, is the above code as efficient/correct as it could be?

    Here column C has the rising values for V, but column A, B, D, E etc contain constants.

    This code works with this set up.

    However, I have applied it to another scenario on another worksheet and it does not run.

    Sub test2()
    Dim Nr As Double
    lastrow = Cells(Rows.Count, "A").End(xlUp).Row
    inarr = Range(Cells(1, 1), Cells(lastrow, 10))
    For i = 4 To lastrow
        Nr = inarr(i, 10)
        Cells(i, 16) = DIP(Nr)
    Next i
    End Sub
     
    Function DIP(Nr As Double) As Double
    DIP = 1 + ((1.996 * 5) / Nr)
    End Function
    Here, the varying input is in column J starting at row 4. The constants have been inputted manually.

    Thanks,
    ITY
    Last edited by Itakeyokes; 02-15-2018 at 11:15 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •