Posted By

Wardy on 10/29/08


Tagged

excel square vba grid-paper


Versions (?)

Excel as Gridpaper for Drawing


 / Published in: Visual Basic
 

URL: http://www.mrexcel.com/tip071.shtml

  1. Sub MakeSquareCells2()
  2. Dim wid As Single
  3. Dim myPts As Single
  4. Dim myRange As Range
  5.  
  6. 'get from user the range to make square cells in.
  7. On Error GoTo TheEnd
  8. Set myRange = Application.InputBox _
  9. ("Select a range in which to create square cells", Type:=8)
  10. On Error Resume Next
  11. If myRange.Cells.Count = 0 Then Exit Sub
  12.  
  13. GetWidth:
  14. 'get from user the width of the cells
  15. wid = Val(InputBox("Input Column Width: "))
  16. If wid > 0 And wid < 0.05 Then
  17. MsgBox "Invalid column width value"
  18. GoTo GetWidth
  19. ElseIf wid <= 0 Then Exit Sub
  20. End If
  21.  
  22. 'don't drive the person crazy watching you work
  23. Application.ScreenUpdating = False
  24. myRange.EntireColumn.ColumnWidth = wid
  25.  
  26. myPts = myRange(1).Width
  27. myRange.EntireRow.RowHeight = myPts
  28.  
  29. 'show the person what you've done
  30. Application.ScreenUpdating = True
  31. TheEnd:
  32. End Sub

Report this snippet  

You need to login to post a comment.