Nested IF

saialkesh

New Member
Joined
Oct 26, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Dear team,

Can someone please help me for a nested if formula. I need to write a formula enable to do the following conditions in one if statement -

NoBuy CurrencySell CurrencyPurchase Value (Column M)Sell Value (Column O)Notional value (Column V)FormulaNotes
1EURUSD0+ V-M * -1If buy currency is EUR, and sale currency is USD, then formula is zero + notional – sale *-1
2EURGBP0+ V-M *-1 *1.28If buy currency is EUR, and sale currency is GBP, then formula is zero + notional – sale *-1 * 1.28
3USDEUR0+ V-M *-1If buy currency is USD, and sale currency is EUR, then formula is zero + notional – sale *-1
4USDGBP0+ V-M *-1If buy currency is USD, and sale currency is GBP, then formula is zero + notional – sale *-1
5GBPEUR0+ V-M *-1 *1.28If buy currency is GBP, and sale currency is EUR, then formula is zero + notional – sale *-1 * 1.28
6GBPUSD0+ V_M *-1If buy currency is GBP, and sale currency is USD, then formula is zero + notional – sale *-1
7Any otherEURV-O *-1 +0If buy currency is any other than EUR and sale currency is EUR, then formula is notional – sale *-1 +zero
8Any otherUSDV-O *-1 +0If buy currency is any other than USD and sale currency is EUR, then formula is notional – sale *-1 +zero
9Any otherGBPV-O *-1 +0If buy currency is any other than GBP and sale currency is EUR, then formula is notional – sale *-1 +zero
10EURAny other0+ V-M *-1 *1.17If buy currency is EUR and sale currency is any other than EUR, then formula is zero + notional – purchase *-1 * 1.17
11USDAny other0+ V-M *-1If buy currency is USD and sale currency is any other than USD, then formula is zero + notional – purchase *-1
12GBPAny other0+ V-M *-1 *1.28If buy currency is GBP and sale currency is any other than GBP, then formula is zero + notional – purchase *-1 * 1.28

Appreciate all the help.

Thank you.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hello, Your condition for buy currency = usd & sell currency = eur have two formula one in row 3rd and other in row 8th. kindly check your condition and clarify your requirement so that we can help you better.
 
Upvote 0
Hello, Your condition for buy currency = usd & sell currency = eur have two formula one in row 3rd and other in row 8th. kindly check your condition and clarify your requirement so that we can help you better.
Hello Neha,
Thank you for the revert. There's a typo on row # 8 and my apologies

For row #8, the condition is if buy currency is any currency other than USD and Sell currency is USD.

Hope that clarifies.
 
Upvote 0
Dear team,

Can someone please help me for a nested if formula. I need to write a formula enable to do the following conditions in one if statement -

NoBuy CurrencySell CurrencyPurchase Value (Column M)Sell Value (Column O)Notional value (Column V)FormulaNotes
1EURUSD0+ V-M * -1If buy currency is EUR, and sale currency is USD, then formula is zero + notional – sale *-1
2EURGBP0+ V-M *-1 *1.28If buy currency is EUR, and sale currency is GBP, then formula is zero + notional – sale *-1 * 1.28
3USDEUR0+ V-M *-1If buy currency is USD, and sale currency is EUR, then formula is zero + notional – sale *-1
4USDGBP0+ V-M *-1If buy currency is USD, and sale currency is GBP, then formula is zero + notional – sale *-1
5GBPEUR0+ V-M *-1 *1.28If buy currency is GBP, and sale currency is EUR, then formula is zero + notional – sale *-1 * 1.28
6GBPUSD0+ V_M *-1If buy currency is GBP, and sale currency is USD, then formula is zero + notional – sale *-1
7Any otherEURV-O *-1 +0If buy currency is any other than EUR and sale currency is EUR, then formula is notional – sale *-1 +zero
8Any otherUSDV-O *-1 +0If buy currency is any other than USD and sale currency is EUR, then formula is notional – sale *-1 +zero
9Any otherGBPV-O *-1 +0If buy currency is any other than GBP and sale currency is EUR, then formula is notional – sale *-1 +zero
10EURAny other0+ V-M *-1 *1.17If buy currency is EUR and sale currency is any other than EUR, then formula is zero + notional – purchase *-1 * 1.17
11USDAny other0+ V-M *-1If buy currency is USD and sale currency is any other than USD, then formula is zero + notional – purchase *-1
12GBPAny other0+ V-M *-1 *1.28If buy currency is GBP and sale currency is any other than GBP, then formula is zero + notional – purchase *-1 * 1.28

Appreciate all the help.

Thank you.
Sorry for the typo -

Row 8 is if Buy currency is any other currency than USD and Sell currency is USD
Row 9 is if Buy currency is any other currency than GBP and Sell currency is GBP
 
Upvote 0
solution with a helper column X

Book1
ABCMOVWX
1NoBuy CurrencySell CurrencyPurchase Value (Column M)Sell Value (Column O)Notional value (Column V)Formula
21EURUSD1002003004001
32EURGBP1002003004281.28
43USDEUR1002003004001
54USDGBP1002003004001
65GBPEUR1002003004281.28
76GBPUSD1002003004001
87Any otherEUR1002003005001
98Any otherUSD1002003005001
109Any otherGBP1002003005001
1110EURAny other1002003004171.17
1211USDAny other1002003004001
1312GBPAny other1002003004281.28
Sheet1
Cell Formulas
RangeFormula
W2:W13W2=V2+IF(OR(B2={"EUR","USD","GBP"}),M2*X2,O2)
 
Upvote 0
Solution
Hello, I am not able to get your formula properly, but i think you can rectify that in the below code as per your need. Please let me know if this code works well for you.

VBA Code:
Sub nested_if()
    
Dim i As Integer
    
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
    If Range("B" & i).Value = "EUR" Then
        Select Case Range("C" & i).Value
            Case "USD": Range("G" & i).Value = 0 + Range("V" & i).Value - (Range("M" & i).Value) * -1
            Case "GBP": Range("G" & i).Value = 0 + Range("V" & i).Value - ((Range("M" & i).Value) * -1) * 1.28
            Case "Any other": Range("G" & i).Value = 0 + Range("V" & i).Value - ((Range("M" & i).Value) * -1) * 1.17
        End Select
            
    ElseIf Range("B" & i).Value = "USD" Then
        Select Case Range("C" & i).Value
            Case "EUR": Range("G" & i).Value = 0 + Range("V" & i).Value - (Range("M" & i).Value) * -1
            Case "GBP": Range("G" & i).Value = 0 + Range("V" & i).Value - (Range("M" & i).Value) * -1
            Case "Any other": Range("G" & i).Value = 0 + Range("V" & i).Value - (Range("M" & i).Value) * -1
        End Select
    ElseIf Range("B" & i).Value = "GBP" Then
        Select Case Range("C" & i).Value
            Case "USD": Range("G" & i).Value = 0 + Range("V" & i).Value - (Range("M" & i).Value) * -1
            Case "EUR": Range("G" & i).Value = 0 + Range("V" & i).Value - ((Range("M" & i).Value) * -1) * 1.28
            Case "Any other": Range("G" & i).Value = 0 + Range("V" & i).Value - ((Range("M" & i).Value) * -1) * 1.28
        End Select
    Else
        Select Case Range("C" & i).Value
            Case "EUR": Range("G" & i).Value = Range("V" & i).Value - (Range("O" & i).Value) * -1 + 0
            Case "GBP": Range("G" & i).Value = Range("V" & i).Value - (Range("O" & i).Value) * -1 + 0
            Case "USD": Range("G" & i).Value = Range("V" & i).Value - (Range("O" & i).Value) * -1 + 0
        End Select
    End If
Next i

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

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