Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel AutoFill Macro

Status
Not open for further replies.

SeisaT

Technical User
Nov 30, 2005
89
LS
I need help in creating a macro that will autofill in a column the numbers in this pattern (1,1,2,2,3,3,4,4,5,5,6,6 etc) and up to 2000.

Anyone to my rescue?

Rgds,
SeisaT



 
Hi,

Don't need a macro.

You can enter in, for instance A2 & A3...

1
2

...then Select those two cells and Drag the Fill Handle, visible in the lower Right-Hand of the selection, down until you get to 2000.

Then IMMEDIATELY Copy. That puts thos 2000 cells in your Clipboard.

Select the cell after the cell containing 2000 and Paste.

Now you have 4000 cells. Just sort and you have the pattern you need.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
if you want a macro...

Code:
Sub SeisaT()
Dim x As Integer, y As Integer, irow As Integer
irow = 2
For x = 1 To 2000
    For y = 0 To 1
        Cells(irow, 1) = x
        irow = irow + 1
    Next y
Next x
End Sub
or
Code:
Sub SeisaT2()
Dim x As Integer
For x = 2 To 4000 Step 2
    Range(Cells(x, 2), Cells(x + 1, 2)) = x / 2
Next x
End Sub
 
BTW, if you need macro help in the future, then please post in forum707.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Thank you very much, Guys!

I think @SkipVought's solution will suffice for now and the note about posting to the appropriate forum is noted.

@Zelgar, I will try your code though I am still a novice and don't know much about programming.

While still at this, can you point me into the right direction regarding an online training site for learning about MS SQL Server Administration?

Rgds,
SeisaT
 
Forum183

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top