Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Looking up the value of a cell in a named range

Hello guys,

I'm have a named range in Worksheet1 which is used back on Worksheet2 (as a
list which from which the user can choose).

Depending on what the user selects I want to perform some calculation, but
that's where my problem starts. For example

my named range contains:
- VB
- VC
- VB+
etc...

Depending on what the user chooses in the list on Worksheet2, i will add 2
numbers if chosen VB, or substract 2 numbers, or multiply numbers...

I've tried If... then, Case Else.. and trying to do something like this:

if SelectedCode = Range("CodesRange").Item Then - which doesn't work OR
for each c in Range("CodesRange") - but this doesn't seem efficient.

Anyone has any suggestions about how i can do this in VBA, as efficiently as
possible?

Thanks in advance!

Memento


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Looking up the value of a cell in a named range

Why don't you use a find?

set c = Range("CodesRange").find(what:=Selectedcode, _
lookin:xlvalues)
if not c is nothing then


"Memento" wrote:

Hello guys,

I'm have a named range in Worksheet1 which is used back on Worksheet2 (as a
list which from which the user can choose).

Depending on what the user selects I want to perform some calculation, but
that's where my problem starts. For example

my named range contains:
- VB
- VC
- VB+
etc...

Depending on what the user chooses in the list on Worksheet2, i will add 2
numbers if chosen VB, or substract 2 numbers, or multiply numbers...

I've tried If... then, Case Else.. and trying to do something like this:

if SelectedCode = Range("CodesRange").Item Then - which doesn't work OR
for each c in Range("CodesRange") - but this doesn't seem efficient.

Anyone has any suggestions about how i can do this in VBA, as efficiently as
possible?

Thanks in advance!

Memento


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
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
named cell range Marilyn Excel Worksheet Functions 2 March 13th 06 07:42 PM
If any cell in named range = 8 then shade named range JJ[_8_] Excel Programming 3 August 26th 05 11:09 PM
First and Last cell of a named range Steven K Excel Programming 2 September 14th 04 12:21 AM


All times are GMT +1. The time now is 07:16 PM.

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

About Us

"It's about Microsoft Excel"