Hi there
I have an set of conditional statements to check which i'm not sure whether to use IF or CASE statement. can u please advice
Find below the code
I'm passing strcode to another function which generates email soCode:If strOnA1 = "Yes" Then strcode = "Hi " + PersonName + " Welcome to Hotel " + HotelName ElseIf strOnA2 = "Yes" Then strcode = "Hi " + PersonName + " Welcome to Hotel " + HotelName ElseIf strOnA3 = "Yes" Then strcode = "Hi " + PersonName + " Welcome to Hotel " + HotelName ElseIf strOnA4 = "Yes" Then strcode = "Hi " + PersonName + " Welcome to Hotel " + HotelName End If If strOnA1 = "No" Then strcode = "Hi " + PersonName + " Sorry, please signup at " + HotelName ElseIf strOnA2 = "No" Then strcode = "Hi " + PersonName + " Sorry, please signup at " + HotelName ElseIf strOnA3 = "No" Then strcode = "Hi " + PersonName + " Sorry, please signup at " + HotelName ElseIf strOnA4 = "No" Then strcode = "Hi " + PersonName + " Sorry, please signup at " + HotelName End If
But for some reason the right condition is not getting picked upCode:.subject = strcode
Last edited by captedgar; 01-28-2010 at 08:07 PM.
Hi
Without knowing which condition is being picked up and which condition you think should be picked up it's difficult to advise. Don't worry at the moment about the difference between If..Then and Select Case structures, the first thing to reconcile is the basic problem.
Can you upload an example workbook so that we can see the problem in context. If you do add a note saying what you expect should be happening.
Regards
Richard Buttrey
If this was useful then please rate it appropriately.
Click the small star iconat the bottom left of my post.
Hi there
I have attached a simple spreadsheet with a table in it
All the cells except the headers in the tables are conditional formatted so that
if i select a cell in the table as No, the colour of the cell turns red
if i select Yes, the cell color turns green and
if i select NA, the cell color turns orange.
My code is below
When i need to select a particular row as Yes or NA, my IF statement is breaking logic inCode:If strOnG8 = "Yes" and Range(RangeFinder("A") + strCurrentRow).Value2 Then strcode = "Hi " + PersonName + " Welcome to Hotel " + HotelName ElseIf strOnH8 = "Yes" and Range(RangeFinder("B") + strCurrentRow).Value2 Then strcode = "Hi " + PersonName + " Welcome to Hotel " + HotelName ElseIf strOnI8 = "Yes" and Range(RangeFinder("C") + strCurrentRow).Value2 Then strcode = "Hi " + PersonName + " Welcome to Hotel " + HotelName ElseIf strOnJ8 = "Yes" and Range(RangeFinder("D") + strCurrentRow).Value2 Then strcode = "Hi " + PersonName + " Welcome to Hotel " + HotelName End If If strOnG8 = "NA" and Range(RangeFinder("A") + strCurrentRow).Value2 Then strcode = "Hi " + PersonName + " Sorry, please signup at " + HotelName ElseIf strOnH8 = "NA" and Range(RangeFinder("B") + strCurrentRow).Value2 Then strcode = "Hi " + PersonName + " Sorry, please signup at " + HotelName ElseIf strOnI8 = "NA" and Range(RangeFinder("C") + strCurrentRow).Value2 Then strcode = "Hi " + PersonName + " Sorry, please signup at " + HotelName ElseIf strOnJ8 = "NA" and Range(RangeFinder("D") + strCurrentRow).Value2 Then strcode = "Hi " + PersonName + " Sorry, please signup at " + HotelName End If 'RangeFinder, strcode, PersonName and HotelName are all global variables called in different functions withinin the code and they are all working fine. There is no dependency of them to the above code
picking the right strcode value independent of whatever the values are in the other cells in
the table
Please advice
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks