jocker_boy
Board Regular
- Joined
- Feb 5, 2015
- Messages
- 83
Hi,
I have already a VBA code that creates a organigram based on a table.
One of the column is called "Entity" and actually one part of the code is this:
And works, if some rows have "PT" in the Colum "Entity" that shape will be fill with the color "RGB(192, 215, 155)".
What i would like, is to create a table in a diferent Sheet, for example "sheet2" where i have a Table (database) with 2 columns:
In cloumn A i would have the Entitys (example: PT, ENG, FR, SP, etc...) and in the column B for each Entity i will fill with a diferent color.
My goal is substitute the "PT" for column A and the RGB(192,215,155) for the correspondent color in column B.
i found already this code, maybe it could help:
Many thanks,
Goncalo
I have already a VBA code that creates a organigram based on a table.
One of the column is called "Entity" and actually one part of the code is this:
Code:
If (oType = "WBS" And oData(nItem, cOrgOffEntity) = "PT") Then
oNode.TextFrame2.TextRange.Font.Bold = False
With oNode.Shapes.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(192, 215, 155)
.Solid
End With
And works, if some rows have "PT" in the Colum "Entity" that shape will be fill with the color "RGB(192, 215, 155)".
What i would like, is to create a table in a diferent Sheet, for example "sheet2" where i have a Table (database) with 2 columns:
In cloumn A i would have the Entitys (example: PT, ENG, FR, SP, etc...) and in the column B for each Entity i will fill with a diferent color.
My goal is substitute the "PT" for column A and the RGB(192,215,155) for the correspondent color in column B.
i found already this code, maybe it could help:
Code:
Function Color
' Purpose Determine the Background Color Of a Cell
' @[B][URL="https://www.mrexcel.com/forum/members/param.html"]param[/URL][/B] rng Range to Determine Background Color of
' @[B][URL="https://www.mrexcel.com/forum/members/param.html"]param[/URL][/B] formatType Default Value = 0
' 0 Integer
' 1 Hex
' 2 RGB
' 3 Excel Color Index
' Usage Color(A1) --> 9507341
' Color(A1, 0) --> 9507341
' Color(A1, 1) --> 91120D
' Color(A1, 2) --> 13, 18, 145
' Color(A1, 3) --> 6
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function Color(rng As Range, Optional formatType As Integer = 0) As Variant
Dim colorVal As Variant
colorVal = Cells(rng.Row, rng.Column).Interior.Color
Select Case formatType
Case 1
Color = Hex(colorVal)
Case 2
Color = (colorVal Mod 256) & ", " & ((colorVal \ 256) Mod 256) & ", " & (colorVal \ 65536)
Case 3
Color = Cells(rng.Row, rng.Column).Interior.ColorIndex
Case Else
Color = colorVal
End Select
End Function
Many thanks,
Goncalo
Last edited: