Excel & VBA---Brain Training
아래의 이벤트프로시져를 복사하여
워크시트모듈시트에 붙여 넣고 (일반 모듈시트가 아니다)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const ROW_LIMIT As Integer = 10
Const COL_LIMIT As Integer = ROW_LIMIT
Const ROW_SIZE As Integer = 19
Const COL_SIZE As Integer = 2.5
Dim arrColor As Variant
arrColor = Array(3, 1, 5, 6, 9, 15)
Dim iX As Integer
Dim iY As Integer
Dim iColor As Integer
iColor = arrColor(Int(Rnd() * UBound(arrColor)))
With Target.Parent.Cells
.ColumnWidth = 8.11
.RowHeight = 13.5
.Clear
End With
For iX = 1 To ROW_LIMIT
Target.Offset(iX - 1).RowHeight = ROW_SIZE
Next
For iY = 1 To COL_LIMIT
Target.Offset(, iY - 1).ColumnWidth = COL_SIZE
Next
With Range(Target, Target.Cells(ROW_LIMIT, COL_LIMIT))
.BorderAround xlContinuous, xlThick, iColor
.Borders(xlInsideHorizontal).Weight = xlThick
.Borders(xlInsideHorizontal).ColorIndex = iColor
.Borders(xlInsideVertical).Weight = xlThick
.Borders(xlInsideVertical).ColorIndex = iColor
End With
End Sub
해당 워크시트상의 아무셀이나 선택하면 ..
아래의 그림과 10*10의 격자틀(Grid)이 만들어진다

이것을 기능을 추가하여 아래의 그림과 같이 문자를 난수로 얻어내어
선택할때마다 문자의 방향이 틀려지게 한다

별도의 함수를 작성하여 위의 프로시져에서 호출하여 배열을
얻어내어 위에 그려지는 Grid에 직접 한번에 뿌려지게 한다
아래의 버튼을 크릭하면 나타나는 문자를 배열에 넣는다고
생각하면 된다
Braintraining_025.