How do i write an excel formula that can work either ways?

chimezie oleka

New Member
Joined
Apr 30, 2018
Messages
6
I want to write an excel formula that can compute commission charged using simple interest rate. The fields will be:

  1. Amount
  2. Percentage
  3. Commission charged
How do i write a formula that can provide answers to any field once the other two fields have been completed?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Thanks chimezie oleka.
But you'll have to put the formulae in the cells every time after use, right.
Put this in the sheet module and try it.
Or you could use this.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim tarCells As Range
    Set tarCells = Range("D8:D10")    '<----- Change as required
    
    If Not Application.Intersect(tarCells, Range(Target.Address)) _
           Is Nothing Then
    Select Case WorksheetFunction.CountA(tarCells)
        Case Is = 0
            Exit Sub
        Case Is = 1
            Exit Sub
        Case Is = 2
            If Cells(10, 4) = "" Then
                Cells(10, 4).Value = Cells(8, 4).Value / 100 * Cells(9, 4).Value
            ElseIf Cells(9, 4) = "" Then
                Cells(9, 4).Value = Cells(10, 4).Value / (Cells(8, 4).Value / 100)
            ElseIf Cells(8, 4) = "" Then
                Cells(8, 4).Value = 100 * (Cells(10, 4).Value / Cells(9, 4).Value)
            End If
    End Select
    End If
End Sub
The range where you use your values is D8 to D10.
Put values in any two cells in this range and you'll get the result in the third cell
You will need to change all the cell references depending on where you'll need it
 
Upvote 0
I forgot to mention to clear the three cells before your next calculation
You can do that if you select another sheet and then this one again if you put this in the sheet module also
Code:
Private Sub Worksheet_Activate()
    Range("D8:D10").ClearContents
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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