cellMatrix.net
Spreadsheet Modeling and Related Topics

About

Formulas, Charts, and Models Created with Microsoft Excel.
More . . .

Statistics

  • Total Entries - 102
  • Current Viewers - 15

Categories

Recent Comments

Syndicate

Validate

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


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  on  10/04  at  10:33 AM


Comment Form

Name: (Required)
E-Mail Address: (Optional)
Location: (Optional)
Web Site Address: (Optional)

Remember my personal information?
Notify me of follow-up comments?

Before submitting your comment, please enter the phrase you see below: