Autofill in macro

G

Guest

Hi
I want to replace in the subprocedure below the part ("G2:G875") with un
undeterminated number of rows, something with xlFillDefault. My concern is
that if I have more rows than 875 it is not going to copy the formula that I
am copying with the autofill.

Range("G2").AutoFill Destination:=Range("G2:G875")

Thanks in advance

Orquidea
 
D

Dave Peterson

Can you look at a different column to determine how far to do the filling?

Dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("g2").autofill _
destination:=.range("g2:g" & lastrow)
end with

I used column A to get that last row.
 
G

Guest

The filling in this case goes as far as G845, but I am creating a macro which
will ran with different amount of data so there will be other times where the
filling will be less than 845 and others where it will be more than 845.
Thanks for your help

Orquidea
 
D

Dave Peterson

I don't understand.

Does this mean that you can't pick out a column to determine the number of rows?

If you were doing it manually, how would you know when to stop?
 
G

Guest

I will be using the macro to run in data that I dump from other computer
system. The dumped file will be with diferent ranges of dates, therefore the
number of rows will vary according to the length of time I run the raw report.

Your subprocedure worked well, Thanks for your help
 
D

Dave Peterson

Ah. I thought you had a follow up question in your previous message.
I will be using the macro to run in data that I dump from other computer
system. The dumped file will be with diferent ranges of dates, therefore the
number of rows will vary according to the length of time I run the raw report.

Your subprocedure worked well, Thanks for your help
 

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