Jackie,
The macro previously presented is an Event macro. If you
type in say “C” (no quotes) and then hit the Enter key, the “C” will automatically turn into the symbol for a Club. However, if you already have data in a range, the macro, as presented, will not be triggered.
Assuming that you have already entered the data, then the macro needs to change to the following. Put this macro into a standard module (not a sheet module).
Code:
Option Explicit
Sub mySymbols()
Dim rng As Range
Dim cell As Variant
Dim ws As Worksheet
Set ws = Worksheets("Sheet1") ‘ CHANGE TO SUIT
Set rng = ws.Range("A1:A20") ‘ CHANGE TO SUIT
For Each cell In rng
With cell
Select Case .Value
Case "C", "c":
.Value = Chr(167) ' Clubs
.HorizontalAlignment = xlCenter
With .Font
.Name = "Symbol"
.Size = 12
End With
Case "D", "d":
.Value = Chr(168) ' Diamonds
.HorizontalAlignment = xlCenter
With .Font
.Name = "Symbol"
.Size = 12
.ColorIndex = 3 ' Red
End With
Case "H", "h":
.Value = Chr(169) ' Hearts
.HorizontalAlignment = xlCenter
With .Font
.Name = "Symbol"
.Size = 12
.ColorIndex = 3 ' Red
End With
Case "S", "s":
.Value = Chr(170) ' Clubs
.HorizontalAlignment = xlCenter
With .Font
.Name = "Symbol"
.Size = 12
End With
.HorizontalAlignment = xlCenter
End Select
End With
Next
End Sub
See this part of the macro:
Case "C", "c":
With Target
.Value = Chr(167) ' Clubs
With .Font
.Name = "Symbol"
.Size = 12
End With
.HorizontalAlignment = xlCenter
End With
In particular, see the first line:
Case "C", "c":
At the moment, if you have a “C” (uppercase) or a “c” (lowercase) in any cell in the range A1:A20, you will get the symbol for a Club. If you want other text/number(s) to also be a Club simply add that text/number(s), enclosed in quotes and separated by a comma, to the Case statement e.g. say you want “Jackie”, “Fred” and the number 10 to be shown as a Club, then change the first line of the above snippet to:
Case "C", "c", “Jackie”, “Fred”, “10”:
(the rest of the code for chr(167))
Any characters (text or numbers) that are not specified in the Case statement will stay as it is e.g. if you enter the letter A, B, Z (whatever) in the range A1:A20, it will remain as A, B or Z.
HTH
Mike