Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Reference Names via VBA

We are converting some of our calculating in our spreadsheets to VBA
due to some of excel limitations. We have numerous 2 dimensional
defined names. If (for example) I have a defined name of "CUTS" that
is 300 x 200 and I wanted to access element (240, 45) how would I do
this in VBA using the defined name "CUTS". Also lets say the user
picks item 6 off of a validation list how could I use VBA to determine
they picked item 6 from the list of 20.

Thank You
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Reference Names via VBA



x = Range("Cuts").Cells(245, 45).Value


For your 2nd question, I think you need to retrieve the Formula1 property of
the Validation object for this cell, then compare the cell value with the
items on that last.

On 25 Oct 2004 13:27:15 -0700, (Network Admin) wrote:

We are converting some of our calculating in our spreadsheets to VBA
due to some of excel limitations. We have numerous 2 dimensional
defined names. If (for example) I have a defined name of "CUTS" that
is 300 x 200 and I wanted to access element (240, 45) how would I do
this in VBA using the defined name "CUTS". Also lets say the user
picks item 6 off of a validation list how could I use VBA to determine
they picked item 6 from the list of 20.

Thank You


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Reference Names via VBA



Be aware that range names can be defined
on workbook level
and worksheet level...

dim r as range

This will set the range for the ACTIVEWORKBOOK!

set r = Range("CUTS")(240,45)

is the shortest way to refence the range objects' default
CELLS method. More often it's used like:

set r = Range("CUTS").Cells(240,45)


It you need to code regardless of whether the book is active...

Set r = Range(Workbooks(1).Name & "!CUTS")(240, 45)
OR
Set r = Workbooks(1).Names("CUTS").RefersToRange(240, 45)

(the first method is slightly faster)

To reference a sheet level name:
either activate the sheet or precede the NAME with the sheetname.

Set r = Range("'[" & Workbooks(1).Name & "]" & 'sheet1!CUTS")(4, 4)
Set r = Workbooks(1).Names("Sheet1!CUTS").RefersToRange(24 0, 45)
Set r = Workbooks(1).Sheets(1).Names("CUTS").RefersToRange (240, 45)

Note again the RANGE method is fastest (approx 30%)





keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(Network Admin) wrote:

We are converting some of our calculating in our spreadsheets to VBA
due to some of excel limitations. We have numerous 2 dimensional
defined names. If (for example) I have a defined name of "CUTS" that
is 300 x 200 and I wanted to access element (240, 45) how would I do
this in VBA using the defined name "CUTS". Also lets say the user
picks item 6 off of a validation list how could I use VBA to determine
they picked item 6 from the list of 20.

Thank You


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Reference Names via VBA

I noticed one thing I left out in my question. The second question
being about validation lists. My list also has a named defined to it
because the list is used elsewhere in multiple places.

Thank You
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting values from names by reference Charlie Smith Excel Discussion (Misc queries) 5 July 17th 09 11:04 PM
reference other worksheets via variable names Huggy Excel Worksheet Functions 4 June 26th 08 05:52 AM
Fixing sheet names is a 3D reference Davidt New Users to Excel 4 January 26th 08 05:43 PM
reference to range names duane Excel Discussion (Misc queries) 3 August 2nd 06 10:15 PM
Remove reference names latha Excel Programming 4 August 3rd 04 01:13 AM


All times are GMT +1. The time now is 01:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"