Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel, refer to the value of a named cell

Status
Not open for further replies.

yoshi88

Technical User
Mar 18, 2001
48
0
0
CA
Hi,

I am using a VB code in excel, and I want to use the value of a named cell in my If...Then...Else code. I can't figure out what I should use to code it.

My cell is name "Test" and my code looks like this:
If cell name "Test" = Red Then
.....
Elseif cell name "Test" = Blue Then
.....
Else
.....
End if



Thanks

Frank
 

Frank,
Code:
Select Case [Test].value
  Case "Red"
   'red code
  Case "Blue"
   'blue code
  Case Else
   'otherwise code
End Select


Skip,
[sub]
[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue][/sub]
 
or - more syntactically correct

theValue = Range("Test").value

[Test]

[ ] means "Evaluate" and the Value is the default property of the range object so VBA can work out what it needs to do...

Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top