Results 1 to 4 of 4

String not working as expected

Threaded View

  1. #1
    Registered User
    Join Date
    09-18-2009
    Location
    Auckland NZL
    MS-Off Ver
    Excel / Access / Word 2007
    Posts
    4

    String not working as expected

    Excel 2007
    I have a VBA procedure for checking a selection (Country) to determine an action.
    Under Option Explicit I have declared Public strCountry as String.
    As part of the procedure I am asking "If strCountry is XYZ Then Do this (etc). If not do something else.
    For some reason within the procedure I am able to identify the user section, but unable to use it in a call to action.
    For example, under a Public Function:
    In the subject worksheet the user has selected "Australia" (without the quotes.)

    strCountry = Worksheets("1-REVENUES").Range("lstCountry").Value
    Msgbox strCountry '[returns "Australia" (without the quotes)]
    MsgBox Worksheets("1-REVENUES").Range("lstCountry").Value '[returns "Australia" (without the quotes)]
    MsgBox strCountry = Worksheets("1-REVENUES").Range("lstCountry").Value '[returns FALSE] ??

    The following (paraphrased)
    If strCountry = "Australia" Then
    [Do This]
    End If
    [Do something else]

    results in [Do something else].

    Why is the call not recognising the string "Australia"?? (or any other string for that matter)

    Any help appreciated.
    Last edited by WilyOne; 11-21-2011 at 08:49 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1