View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default Is there a simple way to generate patterns of numbers in XL ?

Here is some quickie VBA code that worked a few times.
Select the cells that receive the numbers and run the code...
'---
Sub FillErUp()
'Jim Cone - March 2010
Dim sRng As Range
Dim startNum As Variant
Dim repeatNum As Variant
Dim N As Long

startNum = InputBox("Fill in Start Number.", "Easy Does It", "1")
If LenB(startNum) = 0 Then Exit Sub
repeatNum = InputBox("Fill in Repeat Number.", "Easy Does It", "5")
If LenB(repeatNum) = 0 Then Exit Sub

Set sRng = Selection.Columns(1).Cells
If sRng.Count < repeatNum Then
MsgBox "Not enough cells selected. ", vbExclamation, "Hard To Do It"
Exit Sub
End If
Application.ScreenUpdating = False
For N = 1 To sRng.Count
sRng(N).Value = startNum
If N Mod repeatNum = 0 Then
startNum = startNum + 1
End If
Next
Application.ScreenUpdating = True
End Sub
--
Jim Cone
Portland, Oregon USA
(Special Sort... http://www.contextures.com/excel-sort-addin.html )






"Bruce Sinclair"
wrote in message ...
Hi
I often want to generate simple patterns of numbers, but have yet to find an
easy way of doing this in excel. It's really easy in minitab (for example)
to get simple patterns using the 'set' command ...

MTB Set c1
DATA 1( 1 : 72 / 1 )32
DATA End.

This generates (in column 1) 32 1's, then 32 2's, 32 3's ... down to 32 72's
very quickly and easily. I have not yet found anything similar in XL to do
this sort of thing but can't help the feling I'm missing something.

Anyone have any idea how to do this sort of thing in XL easily ?

Yes, I can do it in minitab and copy the column, but can't believe that XL
lacks what I think of as a basic function. What am I missing ? :)
Any help would be most welcome.
Thanks