ASadStudent
New Member
- Joined
- Oct 26, 2022
- Messages
- 20
- Office Version
- 365
- Platform
- Windows
Hello everyone, I want to ask how I can change this line from nothing to more than one.
Everytime I try it doesn't seem to work.
Thanks a lot for helping me
(Here is the line of code of code where it is used in)
Everytime I try it doesn't seem to work.
VBA Code:
If Not rng Is Nothing Then rng.Interior.Color = vbRed
Thanks a lot for helping me
(Here is the line of code of code where it is used in)
VBA Code:
Sub Kijken_2()
Dim omzet As Worksheet, Maandafsluiting As Worksheet
Dim data As Variant, ky As Variant
Dim lr As Long, rw As Long
Dim d As Object, d2 As Object
Dim rng As Range
Set d = CreateObject("Scripting.Dictionary")
Set d2 = CreateObject("Scripting.Dictionary")
Set omzet = Workbooks.Item("Omzet").Sheets("Sheet1")
Set Maandafsluiting = Workbooks.Item("Maandafsluiting").Sheets(1)
lr = omzet.Cells(Rows.Count, 2).End(3).Row
With omzet.Cells(1, 1).Resize(lr, 14)
data = .Value
.Interior.ColorIndex = xlNone
End With
For rw = LBound(data) To UBound(data)
If data(rw, 14) <> 0 Then
ky = data(rw, 2)
If Not d.exists(ky) Then
d(ky) = data(rw, 14) & "|" & rw
End If
End If
Next rw
lr = Maandafsluiting.Cells(Rows.Count, 2).End(3).Row
data = Maandafsluiting.Cells(1, 1).Resize(lr, 6).Formula
For rw = LBound(data) To UBound(data)
ky = data(rw, 2)
d2(ky) = Empty
If d.exists(ky) Then
data(rw, 6) = Split(d(ky), "|")(0)
End If
Next rw
For Each ky In d.keys
If Not d2.exists(ky) Then
rw = Split(d(ky), "|")(1)
If rng Is Nothing Then
Set rng = omzet.Cells(rw, 2)
Else
Set rng = Union(rng, omzet.Cells(rw, 2))
End If
End If
Next
If Not rng Is Nothing Then rng.Interior.Color = vbRed
Maandafsluiting.Cells(1, 6).Resize(UBound(data)).Formula = Application.Index(data, 0, 6)
End Sub