#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 13
Default Excel question

Simple help needed, I want to make a cell return a value when another cell
has a particular value. for example

Part # color
11 red This cell = red, blue, €¦ depending on what Part # is entered.
15 blue
23 violet
18 green
19 brown
21 black

Hope to hear back soon, thanks


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Excel question

You will need VBA code (sample) below.

To enter, right click on worksheet tab, "View Code" and copy and paste code
below.

You will to change the WS_RANGE to that of your Part #s and then extend the
CASE statements..


-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "H1:H10" '<=== change to suit


On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case 1: .Interior.ColorIndex = 3 'red
Case 2: .Interior.ColorIndex = 6 'yellow
Case 3: .Interior.ColorIndex = 5 'blue
Case 4: .Interior.ColorIndex = 10 'green
End Select
End With
End If

HTH

"BillO" wrote:

Simple help needed, I want to make a cell return a value when another cell
has a particular value. for example

Part # color
11 red This cell = red, blue, €¦ depending on what Part # is entered.
15 blue
23 violet
18 green
19 brown
21 black

Hope to hear back soon, thanks


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,268
Default Excel question

Or Excel 2007, there are no limits (except hardware) on the number of
conditions for conditional formatting in 2007


--
Regards,

Peo Sjoblom



"Toppers" wrote in message
...
You will need VBA code (sample) below.

To enter, right click on worksheet tab, "View Code" and copy and paste
code
below.

You will to change the WS_RANGE to that of your Part #s and then extend
the
CASE statements..


-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "H1:H10" '<=== change to suit


On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case 1: .Interior.ColorIndex = 3 'red
Case 2: .Interior.ColorIndex = 6 'yellow
Case 3: .Interior.ColorIndex = 5 'blue
Case 4: .Interior.ColorIndex = 10 'green
End Select
End With
End If

HTH

"BillO" wrote:

Simple help needed, I want to make a cell return a value when another
cell
has a particular value. for example

Part # color
11 red This cell = red, blue, . depending on what Part # is entered.
15 blue
23 violet
18 green
19 brown
21 black

Hope to hear back soon, thanks




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Excel question

Assumes your part numbers are in A1 to A20, change to suit. paste this into
the worksheet code.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A1:A20")) Is Nothing Then
Select Case Target
Case 11
icolor = 3
Case 15
icolor = 5
Case 18
icolor = 4
Case 19
icolor = 9
Case 21
icolor = 1
Case 23
icolor = 7
Case Else
'Anything
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub

Mike


"BillO" wrote:

Simple help needed, I want to make a cell return a value when another cell
has a particular value. for example

Part # color
11 red This cell = red, blue, €¦ depending on what Part # is entered.
15 blue
23 violet
18 green
19 brown
21 black

Hope to hear back soon, thanks


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Excel question


=IF(A1=11,"Red",IF(A1=15,"Blue",IF(A1=18,"Green",I F(A1=23,"Violet",IF(A1=19,"Brown",IF(A1=21,"Black" ,""))))))
"BillO" wrote:

Simple help needed, I want to make a cell return a value when another cell
has a particular value. for example

Part # color
11 red This cell = red, blue, €¦ depending on what Part # is entered.
15 blue
23 violet
18 green
19 brown
21 black

Hope to hear back soon, thanks




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,101
Default Excel question

=IF(A1=11,"Red",IF(A1=15,"Blue",IF(A1=18,"Green",I F(A1=23,"Violet",IF(A1=19,"Brown",IF(A1=21,"Black" ,""))))))

"BillO" wrote:

Simple help needed, I want to make a cell return a value when another cell
has a particular value. for example

Part # color
11 red This cell = red, blue, €¦ depending on what Part # is entered.
15 blue
23 violet
18 green
19 brown
21 black

Hope to hear back soon, thanks


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
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM
Excel question... Jacob Excel Worksheet Functions 1 October 17th 05 06:00 PM
Excel question. Cmeb4uby Excel Worksheet Functions 2 April 9th 05 10:04 PM
Statistical Excel Function Question within Excel 2000... Drew H Excel Worksheet Functions 3 October 31st 04 06:55 PM


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