Cool Excel VBA trick: Write alphabets with Excel
If you've always wanted to create your very own alphabets, then this simple vba code will help you do that easily.
It uses a set of predetermined combination of pattern; you can create yourself or download a list of them from HERE.
See Example creating alphabets A,B,C D
And now the code: You can play with the code by changing any parameter that you want
Option Explicit
Sub writing()
Dim aCaps, a, b As Variant
' Create Your own alphabet patterns or download my pattern list below
aCaps = Array(3, 4, 8, 11, 13, 18, 19, 20, 21, 22, 23, 24, 25, 30, 31, 36, 37, 42)
a = Array(1, 2, 3, 4, 5, 6, 12, 13, 14, 15, 16, 17, 18, 19, 24, 25, 30, 31, 35, 36, 37, 38, 39, 40, 42)
b = Array(1, 2, 3, 4, 5, 6, 7, 12, 13, 17, 18, 19, 20, 21, 22, 23, 25, 29, 30, 31, 36, 37, 38, 39, 40, 41, 42)
'This macro writes the alphabet you created above
writeLetter (b)
End Sub
Sub writeLetter(alphabetPattern As Variant)
'initialize variable
Dim cell As Range
Dim counter AsInteger
Dim i As Integer
selectRange ' Macro to select a 7 x 6 Matrix of cells from the initial position
counter = 1 'initialise counter
'Loop through the selection and color the require cells to draw the pattern
' Patterns comes from the writing macro as alphabetPattern
For Each cell In Selection
If counter <= Selection.Count Then
For i = 0 To UBound(alphabetPattern)
If counter = alphabetPattern(i) Then
cell.RowHeight = 12
cell.ColumnWidth = cell.RowHeight / 6
cell.Interior.Color = vbBlack
End If
Next i
End If
counter = counter + 1
Next cell
End Sub
Sub selectRange()
' Simple macro to select a 7 x 6 matrix of cells
Selection.Resize(1, 1).Select
Selection.Resize(Selection.Rows.Count + 6, _
Selection.Columns.Count + 5).Select
End Sub
No comments :
Post a Comment