Search code examples
excelvba

Special character check mark


I have found a macro that replaces letters with a certain letter and numbers with another letter in a specified range.

Public Const Letters                As String = "abcdefghijklmnopqrstuvwxyz"
Public Const Numbers                As String = "0123456789"
Public Const FoundLetter            As String = "L"
Public Const FoundNumber            As String = "N"

It works perfectly, but I want to use a check mark (ChrW(&H2713)) instead of a letter. So what should I write instead of: As String = "L"?


Solution

  • Using a Sub to assign a value to a public variable.

    Public FoundLetter As String
    
    Sub Init_Var()
        FoundLetter = ChrW(&H2713)
    End Sub
    
    Sub ReplaceNumber()
        Call Init_Var
        ' Replace digit 9 with check mark
        Sheet1.UsedRange.Replace what:="9", Replacement:=FoundLetter, lookat:=xlPart
    End Sub