I have some cells that are formatted as the basis for conditional formatting.
My VBA code looks at those cells formats and assigns the values to variables
I look through each cell and apply the basis formatting to a range.
Some cells I have a set to No Fill and that's visible on the cell as I can see the grid lines.
When it assigns the value to a temp variable it uses 16777215 an when I apply that using conditional formatting it sets it to white.
Is this the correct behaviour or am I missing something?
I don't want to say if colour is 16777215 then make it xlNone as that may be the colour I actually want.
My VBA code looks at those cells formats and assigns the values to variables
I look through each cell and apply the basis formatting to a range.
Some cells I have a set to No Fill and that's visible on the cell as I can see the grid lines.
When it assigns the value to a temp variable it uses 16777215 an when I apply that using conditional formatting it sets it to white.
Is this the correct behaviour or am I missing something?
I don't want to say if colour is 16777215 then make it xlNone as that may be the colour I actually want.
VBA Code:
Sub get_duty_formatting()
Worksheets("format_helper").Cells.Clear
Worksheets("Duties").Range("sm_duties").Copy Worksheets("format_helper").Range("A1")
Worksheets("Duties").Range("da_duties").Copy Worksheets("format_helper").Range("B1")
Worksheets("Duties").Range("atco_duties").Copy Worksheets("format_helper").Range("C1")
Worksheets("Duties").Range("non_operational_duties").Copy Worksheets("format_helper").Range("D1")
Worksheets("Data Assistant").Activate
Worksheets("Data Assistant").Range("B3:AG20").Select
Selection.FormatConditions.Delete
Dim NumRows As Integer, NumCols As Integer
Dim x As Integer, j As Integer
Dim cell_value As String, font_colour As Long, font_bold As Boolean, font_italics As Boolean, fill_colour As Long
Sheets("format_helper").Visible = xlSheetVisible
Sheets("format_helper").Activate
Range("A1").Select
'Set numrows = number of rows of data.
'Set numcols = number of cols of data.
NumRows = Range(ActiveCell, ActiveCell.End(xlDown)).Rows.Count
NumCols = Range(ActiveCell, ActiveCell.End(xlToRight)).Columns.Count
'Establish "For" loop to loop "numcols" number of times.
For j = 2 To NumCols + 1
'Establish "For" loop to loop "numrows" number of times.
For x = 1 To NumRows
cell_value = ActiveCell.Value
Debug.Print cell_value
font_colour = ActiveCell.Font.Color
Debug.Print font_colour
font_bold = ActiveCell.Font.Bold
font_italics = ActiveCell.Font.Italic
fill_colour = ActiveCell.Interior.Color
If ActiveCell.Column = 2 Then
Worksheets("Data Assistant").Activate
With Worksheets("Data Assistant").Range("B3:AG20").FormatConditions.Add(xlCellValue, xlEqual, cell_value)
With .Font
.Color = font_colour
.Bold = font_bold
.Italic = font_italics
End With
With .Interior
.Color = fill_colour
End With
End With
Worksheets("format_helper").Activate
End If
'Selects cell down 1 row from active cell.
ActiveCell.Offset(1, 0).Select
Next
Cells(1, j).Select
If j <= NumCols Then
NumRows = Range(ActiveCell, ActiveCell.End(xlDown)).Rows.Count
End If
Next j
'Sheets("format_helper").Visible = xlSheetVeryHidden
End Sub