Selection AutoFill, Excel 2000 & 2003

J

jfcby

Hello,

If I have alraedy posted this question please forgive me. I can't find
it in my profile or when I do a search. If my other post has already
been answered please give me the link to it. thank you for your help.

I have multiple worksheets that I need to add numbers to cells
incrementing
them by 1 to multiple columns but I was wondering how you can get the
Selection.AutoFill to begin with 21 in A1 and stop at 3500. This is
the code
I've got so far but you have to manually put the destination cell in I
would
like to automatically stop?

Range("A1").Select
ActiveCell.FormulaR1C1 = "31"
Range("A2").Select
ActiveCell.FormulaR1C1 = "32"
Range("A1:A2").Select
Selection.AutoFill Destination:=Range("A:A"),
Type:=xlFillDefault

Thank you for your help,
jfcby
 
M

Mladen_Dj

Hello,

If I have alraedy posted this question please forgive me. I can't find
it in my profile or when I do a search. If my other post has already
been answered please give me the link to it. thank you for your help.

I have multiple worksheets that I need to add numbers to cells
incrementing
them by 1 to multiple columns but I was wondering how you can get the
Selection.AutoFill to begin with 21 in A1 and stop at 3500. This is
the code
I've got so far but you have to manually put the destination cell in I
would
like to automatically stop?

You can try with input box to define last autofill value:

Sub autofill()

Dim MyValue As Integer
Dim r As Integer

MyValue = InputBox("Input last value:")

r = MyValue - 30

Range("A1").Select
ActiveCell.FormulaR1C1 = "31"
Range("A2").Select
ActiveCell.FormulaR1C1 = "32"
Range("A1:A2").Select
Selection.autofill Destination:=Range("A1:A" & r), _
Type:=xlFillDefault
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top