Reputation: 53
I currently have the following code for a message box
'Message box to ensure that the accounting format equals the loan withdrawl country
If txtloanwithcountry = "England" Then
NumberFormat = "_(£* #,##0.00_);_(£* (#,##0.00);_(£* ""-""??_);_(@_)"
Else
MsgBox "The currency used in the loan withdrawl country must be equal to number format"
End If
However, I was wondering how I can input all the countries that uses British Pounds, so when I either type in Wales, Scotland, Nothern-Ireland or England, the Number Format is British Pounds? When I type in other countries, the message box shows. I have tried to use Or Statement, but it doesn't work.
Upvotes: 0
Views: 932
Reputation: 33175
When you do an Or
you need to include the whole comparison. So it would look like
If txtLoanWithCountry = "England" Or txtLoanWithCountry = "Scotland" or txtLoanWithCountry = "Wales" Then
Another method is to create an array, then use the Filter function to see if your country is in the array. If Filter returns a Ubound of -1, it didn't find a match.
Dim vaPounds As Variant
'Create the array of countries
vaPounds = Split("England Northern-Ireland Scotland Wales")
If UBound(Filter(vaPounds, txtLoanWithCountry)) = -1 Then
MsgBox "The currency used in the loan withdrawl country must be equal to number format"
Else
NumberFormat = "_(£* #,##0.00_);_(£* (#,##0.00);_(£* ""-""??_);_(@_)"
End If
Upvotes: 2