Autofill range

W

Wendy

Hi

I'm trying to autofill a column using Selection.AutoFill Destination:=
Range(A1, rowcounter)

where rowcounter = Application.Sheets(2).Range("G1").value
G1 is =CountA(A:A)

The rowcounter has the correct rownumber in it but the auto fill fails with
Method 'Range' of object '_global' failed

What I am doing is using a formula to put the contents of column B with some
additions into column A. It works using
Selection.AutoFill Destination:=
ActiveCell.Range(Selection,Selection.End(x1Down)), Type:=_
x1FillValues
but it fills down to 65536 there are only 1210 rows of data this time.

Thanks

Wendy
 
C

Chip Pearson

Try something like

Dim RowCounter As Long
RowCounter = Range("G1").Value
Selection.AutoFill Destination:=Range(Range("A1"), Cells(RowCounter, "A"))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
W

Wendy

Thanks Chip thats just what I needed.

Wendy

Chip Pearson said:
Try something like

Dim RowCounter As Long
RowCounter = Range("G1").Value
Selection.AutoFill Destination:=Range(Range("A1"), Cells(RowCounter, "A"))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 

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