ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vba: attach a variable name to a selected range (https://www.excelbanter.com/excel-programming/415342-vba-attach-variable-name-selected-range.html)

Jayne22

vba: attach a variable name to a selected range
 
I would like to attach a variable name to a range. Is this possible? And if
so, what do I 'Dim' this variable as (string, integer, etc)?

I need to reuse the range when I run a macro which places a formula into a
cell. I want the macro to place a dsum formula into a cell, but since the
range will always be changing, I need to attach a variable to it.

This does not work:

Dim work_items as String
Sheets("work items").Select
work_items = Range("a1:z6000").Value


joel

vba: attach a variable name to a selected range
 


set work_items = Sheets("work items").Range("a1:z6000").Value


"Jayne22" wrote:

I would like to attach a variable name to a range. Is this possible? And if
so, what do I 'Dim' this variable as (string, integer, etc)?

I need to reuse the range when I run a macro which places a formula into a
cell. I want the macro to place a dsum formula into a cell, but since the
range will always be changing, I need to attach a variable to it.

This does not work:

Dim work_items as String
Sheets("work items").Select
work_items = Range("a1:z6000").Value


ward376

vba: attach a variable name to a selected range
 
You might try using a variable named range - check out Contextures:
http://www.contextures.com/xlNames02.html

Cliff Edwards

Jayne22

vba: attach a variable name to a selected range
 
awesome! thanks for the help!

"ward376" wrote:

You might try using a variable named range - check out Contextures:
http://www.contextures.com/xlNames02.html

Cliff Edwards


Don Guillett

attach a variable name to a selected range
 
Sheets("work items").Range("a1:z6000").name="Whatevernameyoulik e"

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Jayne22" wrote in message
...
I would like to attach a variable name to a range. Is this possible? And if
so, what do I 'Dim' this variable as (string, integer, etc)?

I need to reuse the range when I run a macro which places a formula into a
cell. I want the macro to place a dsum formula into a cell, but since
the
range will always be changing, I need to attach a variable to it.

This does not work:

Dim work_items as String
Sheets("work items").Select
work_items = Range("a1:z6000").Value




All times are GMT +1. The time now is 01:38 AM.

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