VB macro to change shape colours

  • Thread starter Thread starter Sanjay
  • Start date Start date
S

Sanjay

Hi,

I have trying to do the following:

I have 180 graphic items named (shape_DI001 to shape_DI180) and 180 named
values on the spreadsheet (value_DI100 to value_DI180)

So I would like to create a macro that would:

For Counter = 1 To 180

ActiveSheet.Shapes("shape_DI"+ counter).Select

If Range("value_DI" + counter) < 10 Then
Selection.ShapeRange.Line.ForeColor.SchemeColor = 10
Else
Selection.ShapeRange.Line.ForeColor.SchemeColor = 20
End If

Next Counter

Would this be correct way of achieving this?

Thanks
 
Try changing the + to & .
"shape_D1"+counter is a type mismatch but
"shape_D1" & counter automatically converts the counter to a string.

HTH

-John Coleman
 
Probably want to use "shape_DI" & Format(counter,"000") to get a three digit
index with leading zeros.

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top