![]() |
Select case statement - it will not work and i dont understand why! :o(
Hi NG,
Can anyone tell me what i am doing wrong in the below code? In the first version i was actively selecting the rectangle, and it was working. I changed it to a with - statement because it was pretty annoying that the rectangle constantly was selected. But now? thx in advance Thomas -------------------- Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Number Number = Range("a1").Value Select Case Number Case 1 With ActiveSheet.Shapes("Rectangle 1").ShapeRange.Fill .Visible = msoTrue .Solid .ForeColor.SchemeColor = 44 .Transparency = 0.8 End With Case 2 With ActiveSheet.Shapes("Rectangle 1").ShapeRange.Fill .Visible = msoTrue .Solid .ForeColor.SchemeColor = 34 .Transparency = 0.5 End With Case 3 With ActiveSheet.Shapes("Rectangle 1").ShapeRange.Fill .Visible = msoTrue .Solid .ForeColor.SchemeColor = 24 .Transparency = 0.3 End With Case Else With ActiveSheet.Shapes("Rectangle 1").ShapeRange.Fill Visible = msoFalse End With End Select End Sub |
Select case statement - it will not work and i dont understand why! :o(
this worked for me:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Number Number = Range("a1").Value Select Case Number Case 1 With ActiveSheet.Shapes("Rectangle 1") .Visible = msoTrue With .Fill .Solid .ForeColor.SchemeColor = 44 .Transparency = 0.8 End With End With Case 2 With ActiveSheet.Shapes("Rectangle 1") .Visible = msoTrue With .Fill .Solid .ForeColor.SchemeColor = 34 .Transparency = 0.5 End With End With Case 3 With ActiveSheet.Shapes("Rectangle 1") .Visible = msoTrue With .Fill .Solid .ForeColor.SchemeColor = 24 .Transparency = 0.3 End With End With Case Else With ActiveSheet.Shapes("Rectangle 1") .Visible = msoFalse End With End Select End Sub -- Regards, Tom Ogilvy "Thomas" wrote in message ups.com... Hi NG, Can anyone tell me what i am doing wrong in the below code? In the first version i was actively selecting the rectangle, and it was working. I changed it to a with - statement because it was pretty annoying that the rectangle constantly was selected. But now? thx in advance Thomas -------------------- Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim Number Number = Range("a1").Value Select Case Number Case 1 With ActiveSheet.Shapes("Rectangle 1").ShapeRange.Fill .Visible = msoTrue .Solid .ForeColor.SchemeColor = 44 .Transparency = 0.8 End With Case 2 With ActiveSheet.Shapes("Rectangle 1").ShapeRange.Fill .Visible = msoTrue .Solid .ForeColor.SchemeColor = 34 .Transparency = 0.5 End With Case 3 With ActiveSheet.Shapes("Rectangle 1").ShapeRange.Fill .Visible = msoTrue .Solid .ForeColor.SchemeColor = 24 .Transparency = 0.3 End With Case Else With ActiveSheet.Shapes("Rectangle 1").ShapeRange.Fill Visible = msoFalse End With End Select End Sub |
Select case statement - it will not work and i dont understand why! :o(
And for me too. Great!
Thank you |
All times are GMT +1. The time now is 04:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com