Autofill to last row in a database

J

JOn Kunces

I have a large file but it varies in size each month. When i recorded a
macro the file seems to copy down the column in a fixed method as shown below-

Selection.AutoFill Destination:=Range("H2:H15952")
Range("H2:H15952").Select

I was wondering what i can insert in these areas so that it will AutoFill
automatically to the bottom row of column F no matter how many cells are
present.

Please help me out. Thanks
 
B

Bernie Deitrick

Jon,

Selection.AutoFill Destination:=Range("H2:H" & Range("F65536").End(xlUp).Row)

HTH,
Bernie
MS Excel MVP
 
T

tcowen

I am attempting to do basically the same thing and I can't get the
string to work. I am inserting a column for an Id number and need it
to autofill down to the last row of the database. Did you have success
using the string?

Here is a copy of the macro I am attempting to create. Any help would
be appreciated.

Selection.EntireColumn.Insert
Range("A1").Select
ActiveCell.FormulaR1C1 = "Id"
Range("A2").Select
ActiveCell.FormulaR1C1 = "1"
Range("A3").Select
ActiveCell.FormulaR1C1 = "2"
Range("A4").Select
ActiveCell.FormulaR1C1 = "3"
Selection.AutoFill Destination:=Range("B2:B" &
Range("B65536").End(xlUp).Row)
 

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