beste,
In onderstaande formule wordt kolom B toegewezen om in een ander tabblad een kleur toe te wijzen.
Graag wil ik ook kolom D toewijzen.
Helaas lukt mij dat niet.
Weet iemand hier de oplossing voor?
Bij voorbaat dank
In onderstaande formule wordt kolom B toegewezen om in een ander tabblad een kleur toe te wijzen.
Graag wil ik ook kolom D toewijzen.
Helaas lukt mij dat niet.
Weet iemand hier de oplossing voor?
Bij voorbaat dank
Code:
Option Explicit
Public trgValue
'Namen kleuren
Function SelectColor(Optional lngInitialColor As Long = 16777215) As Long
Dim lngResult As Long, lngO As Long, intR As Long, intG As Long, intB As Long, c As Range
Dim firstaddress As String
Dim Sh As Worksheet
lngResult = xlNone
If Not ActiveWorkbook Is Nothing Then
lngO = ActiveWorkbook.Colors(1)
intR = lngInitialColor And 255
intG = lngInitialColor \ 256 And 255
intB = lngInitialColor \ 256 ^ 2 And 255
If Application.Dialogs(xlDialogEditColor).Show(1, intR, intG, intB) = True Then
lngResult = ActiveWorkbook.Colors(1)
ActiveWorkbook.Colors(1) = lngO
End If
End If
SelectColor = lngResult
For Each Sh In Sheets
If Not Sh.Name = "Diensten" Then '(namen org) naam tabblad
With Sh.Columns(2)
Set c = .Find(trgValue, , xlValues, xlWhole)
If Not c Is Nothing Then
firstaddress = c.Address
c.Interior.Color = lngResult
Do
Set c = .FindNext(c)
c.Interior.Color = lngResult
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End With
End If
Next Sh
End Function