I want to compare the sum of two cells which are not in bold font or the color of interior of the cell is empty. I want to compare this sum of values of cells of the column that are together only when the label of the column is "miercoles", "jueves", "viernes" or "sabado" and just coloring the biggest result after consulting the four columns for the first labels 1, 2 , 3 and 4. I've made this code but I'm not saving any range in the variable g. How can I create the dynamic range g?
Sub reuniones_dos_horas()
Dim r As Range
Dim r2 As Range
a = 2
While Sheets("Dinamicos").Cells(27, a) <> ""
b = 1
While Sheets("Dinamicos").Cells(27, a) <= b + 3
c = 2
While Sheets("Dinamicos").Cells(29, c) <> ""
Drev = Sheets("Dinamicos").Cells(29, c)
If Sheets("Dinamicos").Cells(29, c) = "Miercoles" Or Sheets("Dinamicos").Cells(29, c) = "Jueves" Or Sheets("Dinamicos").Cells(29, c) = "Viernes " Or Sheets("Dinamicos").Cells(29, c) = "Sabado" Then
d = 30
While Sheets("Dinamicos").Cells(d + 1, c) <> ""
If Sheets("Dinamicos").Cells(d + 1, c).Interior.Pattern = xlNone And Sheets("Dinamicos").Cells(d, c).Interior.Pattern = xlNone And Sheets("Dinamicos").Cells(d + 1, c).Font.Bold = False And Sheets("Dinamicos").Cells(d, c).Font.Bold = False Then
e = Application.Sum(Sheets("Dinamicos").Cells(d + 1, c), Sheets("Dinamicos").Cells(d, c))
f = Application.Sum(Sheets("Dinamicos").Cells(d + 1, c), Sheets("Dinamicos").Cells(d + 2, c))
If e >= f Then
e_range1 = Sheets("Dinamicos").Range(Cells(d, c), Cells(d + 1, c)).Select
ElseIf f > e Then
f_range1 = Sheets("Dinamicos").Range(Cells(d + 1, c), Cells(d + 2, c)).Select
End If
For Each r2 In Range(Cells(30, c), Cells(44, c))
If r2.Font.Underline = True Then
If r Is Nothing Then
Set r = Range(Cells(r2.Row, c))
Else
Set r = Union(r, Range(Cells(r2.Row, c)))
End If
End If
Next
h = WorksheetFunction.Sum(ActiveRange)
g = WorksheetFunction.Sum(r)
If h >= g Then
Range(List).Activate
Range(List).Font.Underline = True
ElseIf g > h Then
ActiveRange.Select
ActiceRange.Font.Underline = True
Range(List).Font.Underline = False
End If
End If
d = d + 1
Wend
End If
c = c + 1
Wend
b = b + 1
Wend
a = a + 1
Wend
End Sub