kumshan450
New Member
- Joined
- Apr 22, 2022
- Messages
- 3
- Office Version
- 2016
I am currently working in a project where i have change the district color based on its cell value.
For eg in Sikkim state, there are 4 districts.
NORTH SIKKIM DISTIRCT MAP SHOULD CHANGE TO NORMAL COLOUR (GREY) AS ITS VALUE IS LESS THAN 1000
EAST SIKKING DISTRICT MAP SHOULD CHANGE TO BLUE COLOUR AS ITS VALUE IS GREATER THAN 1000
ANS SO FOR REST OF THE TWO DISTRICTS.
ANYTHING GREATER THAN OR EQUAL TO 1000 DISTRICT MAP SHAPE SHOULD CHANGE TO BLUE COLOUR OTHERWISE GREY.
THERE ARE 4 SHAPES IN ASSAM DISTRICTS. ALL SHAPES ARE NAMED BY M1, M2, M3 and M4
VBA CODE
Private Sub CommandButton1_Click()
For i = 1 To 5
API = Sheet1.Cells(i + 1, 2)
Select Case API
Case Is < 1000
Sheet1.Shapes.Range(Array("M" & i)).Fill.ForeColor.RGB = RGB(255, 0, 0)
Case Else
Sheet1.Shapes.Range(Array("M" & i)).Fill.ForeColor.RGB = RGB(255, 50, 0)
End Select
Next i
End Sub
I am trying to import above code but i am getting error - Run time error 1004 The item with the specified name wasn't found.
For eg in Sikkim state, there are 4 districts.
NORTH SIKKIM DISTIRCT MAP SHOULD CHANGE TO NORMAL COLOUR (GREY) AS ITS VALUE IS LESS THAN 1000
EAST SIKKING DISTRICT MAP SHOULD CHANGE TO BLUE COLOUR AS ITS VALUE IS GREATER THAN 1000
ANS SO FOR REST OF THE TWO DISTRICTS.
ANYTHING GREATER THAN OR EQUAL TO 1000 DISTRICT MAP SHAPE SHOULD CHANGE TO BLUE COLOUR OTHERWISE GREY.
ID | Value | DISTRICT |
M1 | 300 | NORTH SIKKIM |
M2 | 200 | WEST SIKKIM |
M3 | 1000 | SOUTH SIKKIM |
M4 | 50000 | EAST SIKKIM |
THERE ARE 4 SHAPES IN ASSAM DISTRICTS. ALL SHAPES ARE NAMED BY M1, M2, M3 and M4
VBA CODE
Private Sub CommandButton1_Click()
For i = 1 To 5
API = Sheet1.Cells(i + 1, 2)
Select Case API
Case Is < 1000
Sheet1.Shapes.Range(Array("M" & i)).Fill.ForeColor.RGB = RGB(255, 0, 0)
Case Else
Sheet1.Shapes.Range(Array("M" & i)).Fill.ForeColor.RGB = RGB(255, 50, 0)
End Select
Next i
End Sub
I am trying to import above code but i am getting error - Run time error 1004 The item with the specified name wasn't found.