If cell in column A contains word then format cell in Column B

Vbanoob98

Board Regular
Joined
Sep 13, 2019
Messages
128
Hi I'm trying to figure out how to do what the title says

CurrencyAmount
EUR500.00
USD600.00
EUR300.00

So basically if Column A has the word "EUR" then format 500.00 to just 500 and then EUR 300.00 to 300 and so on

Seems simple but what I have found so far seems very convoluted

Thanks a lot for your help
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Just needs conditional formatting with a simple rule and the number format set to Number with 0 decimal places.
Book1
AB
1CurrencyAmount
2EUR500
3USD600.00
4EUR300
Sheet5
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B4Expression=A2="EUR"textNO
 
Upvote 0
VBA Code:
Sub formatting()

    Dim rng As Range

    Set rng = Range("B2", "B4")
 
    With rng
        .FormatConditions.Delete
        .FormatConditions.Add Type:=xlExpression, Formula1:="=$A2=""Eur"""
        .FormatConditions(.FormatConditions.Count).NumberFormat = "0"
    End With

End Sub
 
Upvote 0
Thank you!

And If I wanted to add another constraint how would I do it?

"=$C2<>""50"""


adding that to formula2 is not working
 
Upvote 0
You want it if column A = "Eur" and column C doesn't equal 50?
 
Upvote 0
Just going out so if my last post is true then try...

VBA Code:
Sub formattingit()

    Dim rng As Range

    Set rng = Range("B2", "B15")
 
    With rng
        .FormatConditions.Delete
        .FormatConditions.Add Type:=xlExpression, Formula1:="=AND($A2=""Eur"",$C2<>50)"
        .FormatConditions(.FormatConditions.Count).NumberFormat = "0"
    End With

End Sub

Change the range to suit.
 
Upvote 0
Just going out so if my last post is true then try...

VBA Code:
Sub formattingit()

    Dim rng As Range

    Set rng = Range("B2", "B15")

    With rng
        .FormatConditions.Delete
        .FormatConditions.Add Type:=xlExpression, Formula1:="=AND($A2=""Eur"",$C2<>50)"
        .FormatConditions(.FormatConditions.Count).NumberFormat = "0"
    End With

End Sub

Change the range to suit.

Yeah that's exactly what I needed. Thank you
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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