Hi,
I have a table with cells that contain different numbers and have different color backgrounds. I need to get vba to identify all the odd numbers that have a red background. Then I need it to write down the numbers starting from a cell I called ''tulem''. This is what I have so far, it writes down all the red backgrounded numbers that are odd but for some reason it doesn't include negative numbers that also have a red background. How do I get it to include negative numbers aswell? Thank you.
I have a table with cells that contain different numbers and have different color backgrounds. I need to get vba to identify all the odd numbers that have a red background. Then I need it to write down the numbers starting from a cell I called ''tulem''. This is what I have so far, it writes down all the red backgrounded numbers that are odd but for some reason it doesn't include negative numbers that also have a red background. How do I get it to include negative numbers aswell? Thank you.
Code:
Sub arvuta()Dim row, column, t, a, n
Set t = Range("Tulem")
Sheets("Andmed").Select
row = 9
column = 2
a = 1
n = 0
Do Until column = 12
row= 9
Do Until row = 29
n = cells(row, column).Value
If cells(row, column).Interior.ColorIndex = 3 Then
If Int(cells(row, column).Value) Mod 2 = 1 Then
t.cells(a, 1) = cells(row, column)
a = a + 1
End If
End If
row = row + 1
Loop
column = column + 1
Loop
End Sub