You could do something like this:
Sub UserSquare()
Dim UserInput
Dim SomeValue ' what you will put in each cell in the square
Dim intI As Integer
Dim intJ As Integer
UserInput = InputBox("Enter size of square")
SomeValue = "X"
' This assumes you are starting at cell A1
For intI = 1 To UserInput
For intJ = 1 To UserInput
Cells(intI, intJ).Value = SomeValue
Next intJ
Next intI
End Sub
I tried this-
Sub Macro1()
Dim UserInput
Dim I As Integer
Dim J As Integer
Dim TimValue
UserInput = InputBox("Length of Triangle", "Define Triangle")
TimValue = Selection.Copy
For intI = 1 To UserInput
For intJ = 1 To UserInput
Cells(intI, intJ).Value = TimValue
Next intJ
Next intI
End Sub
All I get is "TRUE" in every cell, but I want the number or whatever is in the original cell in every cell in the square.
Oops, ok, I fixed the typo. It's I and J instead of intI and intJ, but I still get "TRUE" instead of the number? Help.
Here is the code:
Sub Macro1()
Dim UserInput
Dim I As Integer
Dim J As Integer
Dim TimValue
UserInput = InputBox("Length of Triangle", "Define Triangle")
TimValue = Selection.Copy
For I = 1 To UserInput
For J = 1 To UserInput
Cells(I, J).Value = TimValue
Next J
Next I
End Sub
What if I don't want to start at cell A1?
I want to start at the cell that has the data I am copying.