Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
susan hayes
 
Posts: n/a
Default IF Statement difficulty

I am trying to add an addition piece of code to my original IF
statement I wrote a week ago by adding another country to it as
follows:

ElseIf country = "Thailand" Then
Cells(60, "B") = "TB"
Cells(61, "B") = "Thailand Batt"
Cells(63, "B") = "THB"

However, when I inserted this into the original, IF Statement and
entered the word Thailand to cell B6 it did not work. But I could get
the needed result in cells B60, B61, and B63 when I entered all the
other countries names in cell B6.

I don't understand why this is happening?

Susan


__________________________________________________ _______

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim country As String
country = Cells(6, "B").Value
If country = "United Kingdom" Then
Cells(60, "B") = "LN"
Cells(61, "B") = "British Pound"
Cells(63, "B") = "GBp"
ElseIf country = "Hong Kong" Then
Cells(60, "B") = "HK"
Cells(61, "B") = "Hong Kong Dollar"
Cells(63, "B") = "HKD"
ElseIf country = "Australia" Then
Cells(60, "B") = "AU"
Cells(61, "B") = "Australian Dollar"
Cells(63, "B") = "AUD"
ElseIf country = "Belgium" Then
Cells(60, "B") = "BB"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Denmark" Then
Cells(60, "B") = "DC"
Cells(61, "B") = "Danish Krone"
Cells(63, "B") = "DNK"
ElseIf country = "Finland" Then
Cells(60, "B") = "FH"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "France" Then
Cells(60, "B") = "FP"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Germany" Then
Cells(60, "B") = "GR"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Italy" Then
Cells(60, "B") = "IM"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Japan" Then
Cells(60, "B") = "JT"
Cells(61, "B") = "Japanese Yen"
Cells(63, "B") = "JPY"
ElseIf country = "Netherlands" Then
Cells(60, "B") = "NA"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "New Zealand" Then
Cells(60, "B") = "NZ"
Cells(61, "B") = "New Zealand Dollar"
Cells(63, "B") = "NZD"
ElseIf country = "Norway" Then
Cells(60, "B") = "NO"
Cells(61, "B") = "Norwegian Krone"
Cells(63, "B") = "NOK"
ElseIf country = "Singapore" Then
Cells(60, "B") = "SP"
Cells(61, "B") = "Singapore Dollar"
Cells(63, "B") = "SPD"
ElseIf country = "South Africa" Then
Cells(60, "B") = "SJ"
Cells(61, "B") = "South African Rand"
Cells(63, "B") = "RAD"
ElseIf country = "Spain" Then
Cells(60, "B") = "SM"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Sweden" Then
Cells(60, "B") = "SE"
Cells(61, "B") = "Swedish Krona"
Cells(63, "B") = "SEK"
ElseIf country = "Switzerland" Then
Cells(60, "B") = "SW"
Cells(61, "B") = "Swiss Franc"
Cells(63, "B") = "CHF"

***Missing piece of code shown above entered here***

Else: Cells(60, "B") = ""
Cells(61, "B") = ""
Cells(63, "B") = ""
End If

End Sub


  #2   Report Post  
Frank Kabel
 
Posts: n/a
Default

Hi
could you post the complete part of your macro which does this check

--
Regards
Frank Kabel
Frankfurt, Germany

"susan hayes" schrieb im Newsbeitrag
...
I am trying to add an addition piece of code to my original IF
statement I wrote a week ago by adding another country to it as
follows:

ElseIf country = "Thailand" Then
Cells(60, "B") = "TB"
Cells(61, "B") = "Thailand Batt"
Cells(63, "B") = "THB"

However, when I inserted this into the original, IF Statement and
entered the word Thailand to cell B6 it did not work. But I could

get
the needed result in cells B60, B61, and B63 when I entered all the
other countries names in cell B6.

I don't understand why this is happening?

Susan


__________________________________________________ _______

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim country As String
country = Cells(6, "B").Value
If country = "United Kingdom" Then
Cells(60, "B") = "LN"
Cells(61, "B") = "British Pound"
Cells(63, "B") = "GBp"
ElseIf country = "Hong Kong" Then
Cells(60, "B") = "HK"
Cells(61, "B") = "Hong Kong Dollar"
Cells(63, "B") = "HKD"
ElseIf country = "Australia" Then
Cells(60, "B") = "AU"
Cells(61, "B") = "Australian Dollar"
Cells(63, "B") = "AUD"
ElseIf country = "Belgium" Then
Cells(60, "B") = "BB"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Denmark" Then
Cells(60, "B") = "DC"
Cells(61, "B") = "Danish Krone"
Cells(63, "B") = "DNK"
ElseIf country = "Finland" Then
Cells(60, "B") = "FH"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "France" Then
Cells(60, "B") = "FP"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Germany" Then
Cells(60, "B") = "GR"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Italy" Then
Cells(60, "B") = "IM"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Japan" Then
Cells(60, "B") = "JT"
Cells(61, "B") = "Japanese Yen"
Cells(63, "B") = "JPY"
ElseIf country = "Netherlands" Then
Cells(60, "B") = "NA"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "New Zealand" Then
Cells(60, "B") = "NZ"
Cells(61, "B") = "New Zealand Dollar"
Cells(63, "B") = "NZD"
ElseIf country = "Norway" Then
Cells(60, "B") = "NO"
Cells(61, "B") = "Norwegian Krone"
Cells(63, "B") = "NOK"
ElseIf country = "Singapore" Then
Cells(60, "B") = "SP"
Cells(61, "B") = "Singapore Dollar"
Cells(63, "B") = "SPD"
ElseIf country = "South Africa" Then
Cells(60, "B") = "SJ"
Cells(61, "B") = "South African Rand"
Cells(63, "B") = "RAD"
ElseIf country = "Spain" Then
Cells(60, "B") = "SM"
Cells(61, "B") = "Euro"
Cells(63, "B") = "EUR"
ElseIf country = "Sweden" Then
Cells(60, "B") = "SE"
Cells(61, "B") = "Swedish Krona"
Cells(63, "B") = "SEK"
ElseIf country = "Switzerland" Then
Cells(60, "B") = "SW"
Cells(61, "B") = "Swiss Franc"
Cells(63, "B") = "CHF"

***Missing piece of code shown above entered here***

Else: Cells(60, "B") = ""
Cells(61, "B") = ""
Cells(63, "B") = ""
End If

End Sub



  #3   Report Post  
susan hayes
 
Posts: n/a
Default

On Tue, 2 Nov 2004 22:03:30 +0100, "Frank Kabel"
wrote:

Hi
could you post the complete part of your macro which does this check


I'm sorry I don't understand what you mean by the complete part of the
macro.
This is exactly as I wrote the code in VBA. When I enter the country
names such as "France" in cell B6, I would get the needed results in
those three cells B60, B61, B63.

Am I doing this wrong?

  #4   Report Post  
Frank Kabel
 
Posts: n/a
Default

Hi
then probably you have entered something else in this cell. Check for
lower/upper case and blanks at the beginning/end

--
Regards
Frank Kabel
Frankfurt, Germany

"susan hayes" schrieb im Newsbeitrag
...
On Tue, 2 Nov 2004 22:03:30 +0100, "Frank Kabel"
wrote:

Hi
could you post the complete part of your macro which does this check


I'm sorry I don't understand what you mean by the complete part of

the
macro.
This is exactly as I wrote the code in VBA. When I enter the country
names such as "France" in cell B6, I would get the needed results in
those three cells B60, B61, B63.

Am I doing this wrong?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statement with Average Function results in #Value! Paul Excel Discussion (Misc queries) 5 December 28th 04 09:11 AM
VBA Command to Look at cell in an If statement Wolf New Users to Excel 3 December 28th 04 12:27 AM
when writing an IF statement what is the syntax for "Not Equal to. NEEDTOKNOW Excel Discussion (Misc queries) 1 December 10th 04 05:45 PM
Combining SUM Function with Nested If Statement Somecallmejosh Excel Discussion (Misc queries) 3 December 6th 04 05:25 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 05:46 PM


All times are GMT +1. The time now is 01:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"