ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Special characters in a string variable (https://www.excelbanter.com/excel-programming/369429-special-characters-string-variable.html)

[email protected]

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.


ChasAA

Special characters in a string variable
 
I tried you code and it works each time

ChasAA

" 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.




All times are GMT +1. The time now is 03:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com