+ Reply to Thread
Results 1 to 3 of 3

two-variable calculations continued ...

  1. #1
    fredonic
    Guest

    two-variable calculations continued ...

    Could you be more specific, as I am still learning to program in excel.

    "Gary''s Student" wrote:

    > Use a worksheet change event macro. It can detect two cells entered and
    > calculate the third, See:
    >
    > http://www.mvps.org/dmcritchie/excel...m#wb_shtChange
    >
    > --
    > Gary''s Student
    >
    >
    > "fredonic" wrote:
    >
    > > If I input a formula e.g. ‘A1+B1=C1’; how do I tell excel to calculate B1 if
    > > I have A1 and C1’s values or A1 if I have the other 2 values – doing all this
    > > using only the 3 original cells



  2. #2
    Bob Phillips
    Guest

    Re: two-variable calculations continued ...

    Gary is suggesting not using a macro, but using code like this

    Private Sub Worksheet_Change(ByVal Target As Range)
    Const WS_RANGE As String = "A1,B1"

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
    With Target
    Me.Cells(.Row, "C").Value = Me.Cells(.Row, "A") + _
    Me.Cells(.Row, "B").Value
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.





    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "fredonic" <[email protected]> wrote in message
    news:[email protected]...
    > Could you be more specific, as I am still learning to program in excel.
    >
    > "Gary''s Student" wrote:
    >
    > > Use a worksheet change event macro. It can detect two cells entered and
    > > calculate the third, See:
    > >
    > > http://www.mvps.org/dmcritchie/excel...m#wb_shtChange
    > >
    > > --
    > > Gary''s Student
    > >
    > >
    > > "fredonic" wrote:
    > >
    > > > If I input a formula e.g. 'A1+B1=C1'; how do I tell excel to calculate

    B1 if
    > > > I have A1 and C1's values or A1 if I have the other 2 values - doing

    all this
    > > > using only the 3 original cells

    >




  3. #3
    Bernie Deitrick
    Guest

    Re: two-variable calculations continued ...

    fredonic,

    You need to do a lot for that, and it must be equation specific: Copy the code below, right click
    on the sheet tab, select "View Code", and paste the code in the window that appears.

    HTH,
    Bernie
    MS Excel MVP

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Cells.Count > 1 Then Exit Sub
    If Intersect(Target, Range("A1:C1")) Is Nothing Then Exit Sub
    If Target.Value = "" Then Exit Sub
    If Application.WorksheetFunction.CountBlank(Range("A1:C1")) <> 1 Then Exit Sub

    Application.EnableEvents = False
    If Range("A1").Value = "" Then
    Range("A1").Value = Range("C1").Value - Range("B1").Value
    End If
    If Range("B1").Value = "" Then
    Range("B1").Value = Range("C1").Value - Range("A1").Value
    End If
    If Range("C1").Value = "" Then
    Range("C1").Value = Range("A1").Value + Range("B1").Value
    End If
    Application.EnableEvents = True
    End Sub



    "fredonic" <[email protected]> wrote in message
    news:[email protected]...
    > Could you be more specific, as I am still learning to program in excel.
    >
    > "Gary''s Student" wrote:
    >
    >> Use a worksheet change event macro. It can detect two cells entered and
    >> calculate the third, See:
    >>
    >> http://www.mvps.org/dmcritchie/excel...m#wb_shtChange
    >>
    >> --
    >> Gary''s Student
    >>
    >>
    >> "fredonic" wrote:
    >>
    >> > If I input a formula e.g. 'A1+B1=C1'; how do I tell excel to calculate B1 if
    >> > I have A1 and C1's values or A1 if I have the other 2 values - doing all this
    >> > using only the 3 original cells

    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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