Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Cell data based on autoshape color

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default Cell data based on autoshape color

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 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Cell data based on autoshape color

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 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
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
Automatically change autoshape color to that of another autoshape T-bone Excel Programming 2 October 24th 08 01:43 AM
Hide Autoshape based on Cell Value tomic Excel Programming 10 July 9th 08 05:33 PM
fill autoshape color with ref cell conditional formatting Julie Excel Worksheet Functions 1 May 16th 08 05:01 PM
How to sum data based on font or cell color? techiesol Excel Worksheet Functions 6 May 24th 06 04:11 PM
Put an autoshape in a cell based on another cells content Jo Excel Worksheet Functions 7 November 12th 04 04:34 PM


All times are GMT +1. The time now is 04:58 AM.

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"