Using Autofill in an Excel Macro

Yevette

Active Member
Joined
Mar 8, 2003
Messages
336
Hello All,

I am using Excel 2000 and I was wondering if someone could tell me how to write a macro to use the Autofill function that will allow for change in the total number of rows. For instance in the example below:

Selection.AutoFill Destination:=Range("K2:K245")

I don't want the range to just be k2:k245 because K245 will change constantly depending on the number of employees.

I tried using the search function for this topic but came up empty handed. I hope this is clear. Thanks a lot for your help.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try something like this:

Selection.AutoFill Destination:=Range("K2:K" & Range("K65536").end(xlup).Row)

Hope this helps!
 
Upvote 0
Hi,

It worked perfectly, I just needed to change the K65536 to J65536. Thanks so much for your help! Have a great day!
 
Upvote 0

Forum statistics

Threads
1,221,701
Messages
6,161,381
Members
451,700
Latest member
Eccymarge

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top