ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   replacing defined names for ranges (https://www.excelbanter.com/excel-programming/370999-replacing-defined-names-ranges.html)

Chris

replacing defined names for ranges
 
If I go to Insert | Name -- Define and define a name as a range, can I just
replace an absolute range in VBA with the named range?

For example my named range is called ValuesX1.
ValuesX1 = offset($C$1,0,0,countif($A:A$,1),1)

When I record a macro and autofill a range in column C, my VBA code looks
like this: Selection.AutoFill Destination:=Range("Y1:Y61")

However my range changes for different worksheets so can I just replace
"Y1:Y61" with ValuesX1?

Bob Phillips

replacing defined names for ranges
 
Yes, just use

Selection.AutoFill Destination:=Range("ValuesX1")

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Chris" wrote in message
...
If I go to Insert | Name -- Define and define a name as a range, can I

just
replace an absolute range in VBA with the named range?

For example my named range is called ValuesX1.
ValuesX1 = offset($C$1,0,0,countif($A:A$,1),1)

When I record a macro and autofill a range in column C, my VBA code looks
like this: Selection.AutoFill Destination:=Range("Y1:Y61")

However my range changes for different worksheets so can I just replace
"Y1:Y61" with ValuesX1?





All times are GMT +1. The time now is 06:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com