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
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