I created a form in VBA that sends data to a table. The whole Excel sheet where the table is has a orange background, but the table, that has no background, since I want the table to have its default format, which already has a background, as you can see here:
.
If I added a new row with info to my table, it'd grow a row, but if I wanted to erase that row and resize the table back, that row would have no background now. Neither the table default background, nor the sheet orange background I want it to have.
I want to write code that:
- if any cell in a range that is all cells in the sheet but the ones in the table has a different background
interior.colorindex
than 45, then make all the cells of the sheet have that background - and, make the cells of the table have no background
interior.colorindex = 0
.
.
Dim irowoffset As Long: irowoffset = Hoja2.Range("table2").Rows.Count
Dim belowtable2 As Range
belowtable2 = Hoja2.Range("table2").Offset("irowoffset")
Dim cell As Range
For Each cell In belowtable2
If cell.Interior.ColorIndex <> 45 Then
Hoja2.Cells.Interior.ColorIndex = 45
Hoja2.Range("table2").Interior.ColorIndex = 0
End If
Next cell