Changin the value in the cell as the whole and not as the word in the cell?

darksniper

Registered User.
Local time
Today, 07:21
Joined
Sep 4, 2005
Messages
108
I have a script that changes country codes into numbers. The issue that I am having at the moment is when I have a cell that contains other words other than the country it changes it too. Also I cannot specify the name of the colum since every excell spreadsheet is different.

Example:

cell 1: Canada
cell 2: In Canada it rains today.

When I would run my Script I would like it to change only Cell 1 since Canada is the only work in the whole cell, and exclude all other cells where Canada is with other words.

so the result would look something like this:

cell 1: 1
cell 2: In Canada it rains today.

Here is part of the script I have. How can I improove it?
Code:
Sub MacroCountry()
'
' MacroCountry Macro
' Macro recorded 12/11/2007
'
' Keyboard Shortcut: Ctrl+Shift+Y
'
    Cells.Replace What:="Canada", Replacement:="1", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False

Thx.
 
thank you, it works like a charm.
 

Users who are viewing this thread

Back
Top Bottom