LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default VBA Variable

Perfect, thanks Jacob

"Jacob Skaria" wrote:

Use SELECT/CASE as below..



Select Case Range("A1")

Case "RED"
'Code for Red

Case "BLUE"
'Code for Blue

Case "GREEN"
'Code for green

Case Else
'Code if else

End Select

If this post helps click Yes
---------------
Jacob Skaria


"Newbie" wrote:

Hi,

I am trying to run a routine based on the value in a cell, for example A1
might contain RED, BLUE or GREEN.
In the VBA I would have

x = Range("A1") .value
goto x
end

RED:
'red routine here
end
BLUE:
'blue routine here
end
GREEN
'green routine here
end

...but it doesn't work, any help much appreciated.

 
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
Assigning a Variable to an Expression that Includes a Variable andVBA Property bluebird[_3_] Excel Programming 3 April 27th 09 07:38 AM
Nothing Keyword Destories Objects rather than just resetting the variable to an empty variable Ronald R. Dodge, Jr.[_2_] Excel Programming 15 December 15th 08 09:19 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 02:14 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"