Advertisement
Guest User

Untitled

a guest
Feb 8th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub hello()
  2.     Dim row As Integer
  3.     Dim col As Integer
  4.     Dim CharPos As Integer
  5.     Name = InputBox("Enter Some text")
  6.     Dim NameLen As Integer
  7.     NameLen = Len(Name) + 1
  8.     For row = 1 To NameLen * 2
  9.         For col = 1 To NameLen
  10.             Cells(row, col).Value = ""
  11.             Cells(row, col).Interior.Color = RGB(255, 255, 255)
  12.         Next col
  13.     Next row
  14.     For row = 1 To NameLen * 2
  15.         For col = 1 To NameLen - 1
  16.             CharPos = (row - (NameLen * col)) + ((col - 1) * NameLen) + col
  17.             If CharPos > 0 And CharPos < NameLen Then
  18.                 Cells(row, col).Value = Mid(Name, CharPos, 1)
  19.                 '                                             first color is black
  20.                Cells(row, col).Interior.ColorIndex = CharPos + 1
  21.             End If
  22.         Next col
  23.     Next row
  24. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement