What does adding cells spiraly mean? Attach a file showing us what you are trying to do. Are you trying to
Create a Fibonacci Sequence
Hi
I added an attachment.
Your attachment is unreadable for me. It has appeared as all WingDings.
"Your attachment is unreadable for me. It has appeared as all WingDings"
Right-click on the file and select 'Save link as'. Now you can save the file where you want and then open it.
Hi Dear
H attached a simple file.
start from a cell like I10 and move spiraling to cell J10 , J11 , I11 , ... anf fill cells by counter.
And what's the maximum value you want?
I find the way by myself!
I change it a little, it works. you can see that:
Sub Spiral_new()
Dim userinput As Long, n As Long, i As Long, j As Long, rngAddr As Range
userinput = InputBox("How many cells for Spiralling?")
n = 1: j = 0: i = 1
Set rngAddr = Cells(10, 10)
Do Until n > userinput
Do Until j >= i
If n <= userinput Then
Set rngAddr = rngAddr.Offset(0, 1)
rngAddr.Value = n
j = j + 1
n = n + 1
Else
Exit Sub
End If
Loop
j = 1
Do Until j >= i
If n <= userinput Then
Set rngAddr = rngAddr.Offset(-1, 0)
rngAddr.Value = n
j = j + 1
n = n + 1
Else
Exit Sub
End If
Loop
i = i + 1
j = 1
Do Until j >= i
If n <= userinput Then
Set rngAddr = rngAddr.Offset(0, -1)
rngAddr.Value = n
j = j + 1
n = n + 1
Else
Exit Sub
End If
Loop
j = 1
Do Until j >= i
If n <= userinput Then
Set rngAddr = rngAddr.Offset(1, 0)
rngAddr.Value = n
j = j + 1
n = n + 1
Else
Exit Sub
End If
Loop
i = i + 1
j = 1
Loop
Set rngAddr = Nothing
End Sub
You should also include something to clear the area before a new one