i would like to write vba to fill a "chess Board" Matrix (8X8) With Powers Of 2...
starting with 2^0 and ending with 2^63...
(i suppose, click a button/icon and have the numbers fill in/populate...)
???
thank you...
i would like to write vba to fill a "chess Board" Matrix (8X8) With Powers Of 2...
starting with 2^0 and ending with 2^63...
(i suppose, click a button/icon and have the numbers fill in/populate...)
???
thank you...
Re: Fill "chess Board" Matrix With Powers Of 2...
This should do it
this is a fun one:
Re: Fill "chess Board" Matrix With Powers Of 2...
Here's some code to play with...
Option Explicit
Sub DoIt()
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
'Uncomment this line to put formulas in cells
'pFormulas
'OR...
'Uncomment this line to put answers in cells
'Pof2
'Or use pFormulas then Copy/Pastespecial/Values
' to put answers in cells
FitAndFormat
DrawLines
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Sub pFormulas()
'Written by Mikerickson: Ozgrid
Range("A1:H8").FormulaR1C1 = "=2^(8*(ROW()-1)+COLUMN()-1)"
End Sub
Sub Pof2()
Dim c As Long
Dim r As Long
Dim pwr As Long
'set as minus 1 so first incr in loop will be to zero
pwr = -1
For r = 1 To 8
For c = 1 To 8
pwr = pwr + 1
Cells(r, c) = 2 ^ pwr
Next c
Next r
End Sub
Sub FitAndFormat()
Range("A1:H8").Select
With Selection
'format as number
.NumberFormat = "0"
'fit all
.Columns.AutoFit
End With
End Sub
Sub DrawLines()
Range("A1:H8").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Range("A1").Select
End Sub
Display More
Don’t have an account yet? Register yourself now and be a part of our community!