PC Review


Reply
Thread Tools Rate Thread

Cell data based on autoshape color

 
 
T-bone
Guest
Posts: n/a
 
      29th Oct 2008
Hi all

I am using the formula below to assign a number to a cell based on the color
of an autoshape (oval).
My problem is that i have multiple autoshapes on the same sheet. I need each
autoshape to assign a number to a corresponding cell.
When i try to just copy the formula and change autoshape name and cell
number, i get an error message.
I assume you can't have two Worksheet_SelectionChange.
Please help me

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor = 11
Then
Range("A1").Value = 1
ElseIf Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor =
34 Then
Range("A1").Value = 2
ElseIf Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor =
10 Then
Range("A1").Value = 3
Else: Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor = 10
Range("A1").Value = 4
End If

End Sub


-T
 
Reply With Quote
 
 
 
 
Ken
Guest
Posts: n/a
 
      29th Oct 2008
T
You can't have two Worksheet_SelectionChange Events, but you can have
one that does two things. I think you should look into the Select
Case statement, and see if you can get something like this to do what
you want:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Select Case Sheets("Consolidation").Shapes("Oval
1").Fill.ForeColor.SchemeColor
Case 11
Range("A1").Value = 1
Case 34
Range("A1").Value = 2
Case 10
Range("A1").Value = 3
Case Else
Range("A1").Value = 4
End Select

Select Case Sheets("Consolidation").Shapes("Oval
2").Fill.ForeColor.SchemeColor
Case 11
Range("A2").Value = 1
Case 34
Range("A2").Value = 2
Case 10
Range("A2").Value = 3
Case Else
Range("A2").Value = 4
End Select


End Sub


Good luck.

Ken
Norfolk, Va

On Oct 28, 8:58�pm, T-bone <Tb...@discussions.microsoft.com> wrote:
> Hi all
>
> I am using the formula below to assign a number to a cell based on the color
> of an autoshape (oval).
> My problem is that i have multiple autoshapes on the same sheet. I need each
> autoshape to assign a number to a corresponding cell.
> When i try to just copy the formula and change autoshape name and cell
> number, i get an error message.
> I assume you can't have two Worksheet_SelectionChange.
> Please help me
>
> Code:
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> If Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor = 11
> Then
> Range("A1").Value = 1
> ElseIf Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor =
> 34 Then
> Range("A1").Value = 2
> ElseIf Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor =
> 10 Then
> Range("A1").Value = 3
> Else: Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor= 10
> Range("A1").Value = 4
> End If
>
> End Sub
>
> -T


 
Reply With Quote
 
T-bone
Guest
Posts: n/a
 
      29th Oct 2008
Cheers Ken
That was spot on!
thanks

T

"Ken" wrote:

> T
> You can't have two Worksheet_SelectionChange Events, but you can have
> one that does two things. I think you should look into the Select
> Case statement, and see if you can get something like this to do what
> you want:
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
>
> Select Case Sheets("Consolidation").Shapes("Oval
> 1").Fill.ForeColor.SchemeColor
> Case 11
> Range("A1").Value = 1
> Case 34
> Range("A1").Value = 2
> Case 10
> Range("A1").Value = 3
> Case Else
> Range("A1").Value = 4
> End Select
>
> Select Case Sheets("Consolidation").Shapes("Oval
> 2").Fill.ForeColor.SchemeColor
> Case 11
> Range("A2").Value = 1
> Case 34
> Range("A2").Value = 2
> Case 10
> Range("A2").Value = 3
> Case Else
> Range("A2").Value = 4
> End Select
>
>
> End Sub
>
>
> Good luck.
>
> Ken
> Norfolk, Va
>
> On Oct 28, 8:58�pm, T-bone <Tb...@discussions.microsoft.com> wrote:
> > Hi all
> >
> > I am using the formula below to assign a number to a cell based on the color
> > of an autoshape (oval).
> > My problem is that i have multiple autoshapes on the same sheet. I need each
> > autoshape to assign a number to a corresponding cell.
> > When i try to just copy the formula and change autoshape name and cell
> > number, i get an error message.
> > I assume you can't have two Worksheet_SelectionChange.
> > Please help me
> >
> > Code:
> > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> > If Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor = 11
> > Then
> > Range("A1").Value = 1
> > ElseIf Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor =
> > 34 Then
> > Range("A1").Value = 2
> > ElseIf Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor =
> > 10 Then
> > Range("A1").Value = 3
> > Else: Sheets("Consolidation").Shapes("Oval 1").Fill.ForeColor.SchemeColor = 10
> > Range("A1").Value = 4
> > End If
> >
> > End Sub
> >
> > -T

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Cell Background Color based on data from another cell Speedy Microsoft Excel Misc 2 16th Mar 2009 04:10 PM
RE: Formula to populate data in a cell based on another cell's color Luke M Microsoft Excel Misc 0 6th Feb 2009 04:12 PM
Formula to populate data in a cell based on another cell's color Cassie Microsoft Excel Misc 0 6th Feb 2009 03:28 PM
How do I change cell color based upon data range within the cell? =?Utf-8?B?Q2hyaXMgU2FuZGVycw==?= Microsoft Excel Worksheet Functions 1 6th Mar 2006 08:59 PM
Fill color in autoshape based on cell data =?Utf-8?B?Sm9kaQ==?= Microsoft Excel Misc 3 7th Jun 2004 11:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:08 PM.