How to transfer the length of one column to a formula in Visual ba

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a column A of variable length (say 100 cells). I have a formula in J2
which I wish to pull down for that number of cells.

Range ("J2").Select
Selection.Autofill Destination:=Range("J2:J101"), Type:=xlFillDefault.

How do I get the length of Column A to replace the term 'J101' in this
formula?

Thanks
 
Thanks.
This works alright except that I have further data in cells J102-J106 which
now get overwritten. I only want to fill the cells in Column J which
correspond to the number of cells I have in Column A, no more and no less.
 
dim LastRow as long

with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("j2").autofill _
destination:=.range("J2:J" & lastrow), type:=xlfilldefault
end with
 
Thanks Dave; running well

Dave Peterson said:
dim LastRow as long

with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("j2").autofill _
destination:=.range("J2:J" & lastrow), type:=xlfilldefault
end with
 
Back
Top