Using a Named Field for Autofill

Solved/Closed
excel987 Posts 3 Registration date Tuesday June 11, 2019 Status Member Last seen June 12, 2019 - Jun 12, 2019 at 12:25 AM
excel987 Posts 3 Registration date Tuesday June 11, 2019 Status Member Last seen June 12, 2019 - Jun 12, 2019 at 10:52 AM
I am performing an Autofill using a macro. Is there a way to enter the ranges using a "Named Field" in the macro without having to hardcode them in the macro? See my code below. I would like to avoid hard coding D23.

Range("D23").Select
Selection.AutoFill Destination:=Range("D23:D" & Range("C" & Rows.Count).End(xlUp).Row), Type:=xlFillSeries

Thanks!
Related:

1 response

Blocked Profile
Jun 12, 2019 at 06:57 AM
You can initialize a variable, and use it. What is going to determine what that first value is? Take a look:


Firstrange="A1"

Selection.AutoFill Destination:=Range(Firstrange&":D" & Range("C" & Rows.Count).End(xlUp).Row), Type:=xlFillSeries

So as you see, we still have to initialize the variable with some usable range. Do you see the issue?
2
excel987 Posts 3 Registration date Tuesday June 11, 2019 Status Member Last seen June 12, 2019
Jun 12, 2019 at 10:52 AM
Hi ac3mark,
Thank you so much for your help. Your code worked perfectly.
0