Share via

Ohm's Law Calcularor

Anonymous
2016-12-07T22:28:19+00:00

I need to build a calculator with 4 possible inputs where any 2 of the inputs is used to calculate the others. Just like the Ohms law where you have 4 variables of Voltage, Current, Resistance and Power. Any of the 2 can be used to calculate the others. Writing out the formulas shows there are 3 different ways to calculate each factor. How do I make a calculator using the combinations shown in the picture?

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Anonymous
    2016-12-11T21:29:45+00:00

    Replace  section  #1 in the macro with this one.

         '#1

        If volt And Amp <> "" Then

            Range("C6") = volt * Amp

            sqrA = Amp * Amp

            Range("C5") = Range("C6") / sqrA

    If your question is answered, would you mark the post Anwered.

    Was this answer helpful?

    0 comments No comments

15 additional answers

Sort by: Most helpful
  1. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2016-12-10T10:03:25+00:00

    Copy the macro in a general module.

    [coff, coff]

    Why a macro for that?

    If we have different cells for input and output we can accomplish that with formulas.

    And IMHO it is easier to create the formulas if we use named cells:

    A3 as E

    A4 as I

    A5 as R_  (because R is not possible as name in Excel)

    A6 as W

    Okay, there are 3 possible formulas to calculate E (Volts):

    =SQRT(W*R_)

    =W/I

    =I/R_

    But that would cause error values if (e.g.) I is empty. So we have to check for empty cells:

    =IF(OR(ISBLANK(W),ISBLANK(R_)),"",SQRT(W*R_))

    =IF(OR(ISBLANK(W),ISBLANK(I)),"",W/I)

    =IF(OR(ISBLANK(R_),ISBLANK(I)),"",I*R_)

    At last we can combine this 3 formulas, just by replace the "" with the next formula and get:

    =IF(OR(ISBLANK(W),ISBLANK(R_)),IF(OR(ISBLANK(W),ISBLANK(I)),IF(OR(ISBLANK(R_),ISBLANK(I)),"",I*R_),W/I),SQRT(W*R_))

    Based on this, the other formulas should no longer be difficult to create.

    Andreas.

    Was this answer helpful?

    2 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2016-12-09T22:40:08+00:00

    Set up your form like above in the same range.

    Copy the macro in a general module.

    Set up a button to run the macro.

    I did a quick test so check it good.

    Macro below:..............

    Sub CALC()

        Dim volt As Range, Amp As Range, ohms As Range, watt As Range

        Dim sqrA As Long, sqrV As Long, ap, myap, ans, vt, mysqr As Long

        Range("C3:C6").ClearContents

        Set volt = Range("A3")

        Set Amp = Range("A4")

        Set ohms = Range("A5")

        Set watt = Range("A6")

        If volt <> "" Then

            Range("C3") = volt

        End If

        If Amp <> "" Then

            Range("C4") = Amp

        End If

        If ohms <> "" Then

            Range("C5") = ohms

        End If

        If watt <> "" Then

            Range("C6") = watt

        End If

        '#1

        If volt And Amp <> "" Then

            Range("C6") = volt * Amp

            sqrA = Amp * Amp

            Range("C5") = watt / sqrA

            '#2

        ElseIf volt And watt <> "" Then

            Range("C4") = watt / volt

            sqrV = volt * volt

            Range("C5") = sqrV / watt

            '#3

        ElseIf volt And ohms <> "" Then

            Range("C4") = volt / ohms

            sqrV = volt * volt

            Range("C6") = sqrV / ohms

            '#4

        ElseIf Amp And ohms <> "" Then

            Range("C3") = Amp * ohms

            sqrA = Amp * Amp

            Range("C6") = sqrA * ohms

            '#5

        ElseIf Amp And watt <> "" Then

            Range("C3") = watt / Amp

            sqrA = Amp * Amp

            Range("C5") = watt / sqrA

            '#6

        ElseIf ohms And watt <> "" Then

            vt = watt * ohms

            mysqr = Sqr(vt)

            Range("C3") = mysqr

            ap = watt / ohms

            myap = Sqr(ap)

            Range("C4") = myap

        End If

    End Sub

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2016-12-08T13:18:48+00:00

    All formulas should show row 3 not 5.

    My mistake, before I copied the information, I move the rows.

    To use the form, erase row 3 above and fill in the 2 variable you have then below it will give you one more variable that you fill in above to get the last one.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2016-12-08T01:16:34+00:00

    Is this what you want?

    Edit :

    See the other sample below.

    All formulas should show row 3 not 5.

    Was this answer helpful?

    0 comments No comments