Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default VB macro to change shape colours

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default VB macro to change shape colours


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

Sanjay wrote:
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default VB macro to change shape colours

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

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"John Coleman" wrote in message
ups.com...

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

Sanjay wrote:
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default VB macro to change shape colours

Good observation!

Jon Peltier wrote:
Probably want to use "shape_DI" & Format(counter,"000") to get a three digit
index with leading zeros.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"John Coleman" wrote in message
ups.com...

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

Sanjay wrote:
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



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
how do i change the colours of my pie graph? Shane Devenshire Charts and Charting in Excel 0 March 5th 09 11:58 PM
Colours of cells change Matt Excel Discussion (Misc queries) 0 January 28th 09 10:40 AM
Change Shape Name dthmtlgod Excel Programming 1 January 11th 06 06:08 PM
Using If Statements to change colours b_dhan Excel Programming 1 August 19th 04 05:55 AM
VBA to change chart colours Newbie Excel Programming 3 August 9th 04 12:41 PM


All times are GMT +1. The time now is 07:55 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"