Trouble with Autofill

P

Peter Bernadyne

Hello,

I'm stumped over an error message I get trying to use an autofill in m
macro. I am copying a group of values in a range, as follows:

Range("A1:C1").

and attempting to autofill as follows:

Selection.Autofill Destination:=range(ActiveCell, Cells(fill, 3))

Where 'fill' is a variable that I use to measure the range for which
require the autofill.

The destination is a separate worksheet but everything should be fille
in columns A:C.

When I try this, I get the error message:

"Autofill method of Range class failed"

Would anyone be able to point out to me what my error is, please?

Any help much appreciated
 
M

mudraker

when using range you supply a single cell address as a1 or a range a
a1:c1

your code does not keep this format

ActiveCell would be better as ActiveCell.Address

their is no :

Cells(fill, 3) does not give an address in as c1 forma
 
P

Peter Bernadyne

Thank you for your reply. I see your reasoning, but I've used this cod
before which has worked fine for me.

Here's what currently works in another workbook of mine. There's a lo
of extraneous stuff in it, but I thought I'd include a few lines befor
and after, just in case.

If ActiveCell = 0 Then
ActiveCell.Offset(0, 3).Select
If monesss > 1 Then
ActiveCell.FormulaR1C1 = 0
ActiveCell.range("A1").Select
Selection.Autofill Destination:=range(ActiveCell, Cells(moness
+ topmone, 19))
ElseIf monesss = 1 Then
ActiveCell.FormulaR1C1 = 0
End If
End If

where again, 'monesss' and 'topmone' are variables I use to count th
fill range requirement. Does the Autofill code here fit the c1 forma
you refer to?

You'll have to forgive my ignorance, as I am an Excel beginner.

Thanks again,

-Pet
 

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