RGB Colors for shapes

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

RGB Colors for shapes

Post by Stefan_Sand »

hi,

i have some functions, where i can manipulate shapes like coloring them by numbers.
what i am searching for is a solution to adopt my code, that i can color the shapes with rgb colors numbers. to be precise i want to give it the rgb color numbers by cell entries (only the number).
how can i adopt this code to get it out???:

Function ShapeCol3(Name As String, RGB) '-> r, g, b.... how??
Dim rng As Range

Application.Volatile
With ActiveSheet.Shapes(Name)
.Fill.ForeColor.RGB = RBG(rng.Offset(0, 1).Value, rng.Offset(0, 2).Value, rng.Offset(0, 3).Value)
End With
End Function

and see the workbook
You do not have the required permissions to view the files attached to this post.

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: RGB Colors for shapes

Post by rory »

Why not pass the R, G and B arguments separately as Byte?
Regards,
Rory

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: RGB Colors for shapes

Post by Stefan_Sand »

ok, and how do i?

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: RGB Colors for shapes

Post by rory »

Code: Select all

Function ShapeCol3(Name As String, Red as Byte, Green as Byte, Blue as Byte)
Application.Volatile
With ActiveSheet.Shapes(Name)
.Fill.ForeColor.RGB = RBG(Red, Green, Blue)
End With
End Function
Regards,
Rory

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: RGB Colors for shapes

Post by Stefan_Sand »

ok, but it says, function or sub not defined with a link to RGB...

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: RGB Colors for shapes

Post by rory »

I didn't spot your original typo - it should be RGB and not RBG!
Regards,
Rory

User avatar
Stefan_Sand
4StarLounger
Posts: 415
Joined: 29 Mar 2010, 11:50
Location: Vienna, Austria

Re: RGB Colors for shapes

Post by Stefan_Sand »

cool, thank You!!!