Square Cells with VBA

I recently found the following procedure posted as part of a comment at the Excel-Tips Blog. The procedure makes all of the cells in the worksheet grid square. It might come in handy some time.

Sub SquareCells()
    Dim i As Integer
    For i = 1 To 4
        With ActiveSheet
            .Columns.ColumnWidth = _
            .Columns("A").ColumnWidth / .Columns("A").Width * _
            .Rows(1).Height
        End With
    Next
End Sub

Posted on September 06, 2008 | Filed under: VBA | Comments (1) | Permalink
Page 1 of 1 pages

Comments

I have used this code for ages…whenever I design a new form or a template in Excel I always start with a graph paper

Sub graph_paper()
Dim desired As Double, looper As Integer
Cells.ColumnWidth = 8.43
Cells.RowHeight = 12.75
cm = Application.InputBox(“Enter Square Length in Cm”, Type:=1)
If cm = False Then Exit Sub
desired = cm * (0.393700787401575) * 72
Application.ScreenUpdating = False
For looper = 1 To 10
ActiveSheet.Columns.ColumnWidth = desired * ActiveSheet.Columns.ColumnWidth / [A1].width
ActiveSheet.Columns.RowHeight = desired * ActiveSheet.Columns.RowHeight / [A1].Height

If [A1].Height = [A1].width Then Exit For
Next
Application.ScreenUpdating = True
End Sub

Posted by .(JavaScript must be enabled to view this email address)  on  10/04  at  10:33 AM
Page 1 of 1 pages

Comment Entry

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?

Statistics

  • Total Entries - 136
  • Current Viewers - 27

Categories

Entries by Day

Jul - 2010
S M T W T F S
27 28 29 30 1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Recent Comments

Syndicate