+ Reply to Thread
Results 1 to 2 of 2

Special characters in a string variable

  1. #1

    Special characters in a string variable

    Here's my abbreviated code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    For each cell in Target
    If cell.column = 1 and cell.row > 1 Then
    ticker = CStr(UCase(Trim(cell.value)))
    Call LinkRef (ticker)
    End if
    Next cell
    End Sub


    Sub LinkRef(ticker)
    MsgBox ticker
    End Sub

    Of course the full procedure does more than display the message box.
    The problem I'm having is that if the value in the target cell begins
    with a special character, like $ or % as in $DJI or %GOOG, the sub
    routine does not seem to execute. I've tried removing the UCase(),
    Trim() and Cstr() to see if any of those could be the culprit, but no
    such luck. Any insight into what might be the cause here? Any
    solutions?

    Thanks.


  2. #2
    ChasAA
    Guest

    RE: Special characters in a string variable

    I tried you code and it works each time

    ChasAA

    "[email protected]" wrote:

    > Here's my abbreviated code:
    >
    > Private Sub Worksheet_Change(ByVal Target As Range)
    > For each cell in Target
    > If cell.column = 1 and cell.row > 1 Then
    > ticker = CStr(UCase(Trim(cell.value)))
    > Call LinkRef (ticker)
    > End if
    > Next cell
    > End Sub
    >
    >
    > Sub LinkRef(ticker)
    > MsgBox ticker
    > End Sub
    >
    > Of course the full procedure does more than display the message box.
    > The problem I'm having is that if the value in the target cell begins
    > with a special character, like $ or % as in $DJI or %GOOG, the sub
    > routine does not seem to execute. I've tried removing the UCase(),
    > Trim() and Cstr() to see if any of those could be the culprit, but no
    > such luck. Any insight into what might be the cause here? Any
    > solutions?
    >
    > Thanks.
    >
    >


+ Reply to Thread

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