snowdyce
10-16-2012, 08:31 AM
Hello experts,
I am new to the site and to VBA. I have some code that loops for each month. I copied and pasted the code for each month making the small adjustments to the Rows/columns. Each Month performs correctly except for December, I get a Runtime '13' type mismatch error. I think it has something to do with the cell type when asking if the cell is blank (""). When I change that to 0, the error doesn't occur. Below is some code for three months. Any help on how to get past this error would be much appreciated! Thanks I have bolded the line that is highlighted when I debug the error.
''Oct
Oct_TX = ActiveSheet.Cells(21 + i, 33).Value ' TX amount for Oct
Oct_CC = ActiveSheet.Cells(21 + i, 14).Value 'Oct CC amount after refresh
If Oct_TX <> 0 And Oct_CC = "" And ActiveSheet.Cells(21 + i, 2).Interior.Color = RGB(197, 217, 241) Then ' if TX is populated and CC is blank
ActiveSheet.Cells(21 + i, 14).Value = Oct_TX
End If
''Nov
Nov_TX = ActiveSheet.Cells(21 + i, 34).Value ' TX amount for Nov
Nov_CC = ActiveSheet.Cells(21 + i, 15).Value 'Nov CC amount after refresh
If Nov_TX <> 0 And Nov_CC = "" And ActiveSheet.Cells(21 + i, 2).Interior.Color = RGB(197, 217, 241) Then ' if TX is populated and CC is blank
ActiveSheet.Cells(21 + i, 15).Value = Nov_TX
End If
''Dec
Dec_TX = ActiveSheet.Cells(21 + i, 35).Value ' TX amount for Nov
Dec_CC = ActiveSheet.Cells(21 + i, 16).Value 'Dec CC amount after refresh
If Dec_TX <> 0 And Dec_CC = "" And ActiveSheet.Cells(21 + i, 2).Interior.Color = RGB(197, 217, 241) Then ' if TX is populated and CC is blank
ActiveSheet.Cells(21 + i, 16).Value = Dec_TX
End If
I am new to the site and to VBA. I have some code that loops for each month. I copied and pasted the code for each month making the small adjustments to the Rows/columns. Each Month performs correctly except for December, I get a Runtime '13' type mismatch error. I think it has something to do with the cell type when asking if the cell is blank (""). When I change that to 0, the error doesn't occur. Below is some code for three months. Any help on how to get past this error would be much appreciated! Thanks I have bolded the line that is highlighted when I debug the error.
''Oct
Oct_TX = ActiveSheet.Cells(21 + i, 33).Value ' TX amount for Oct
Oct_CC = ActiveSheet.Cells(21 + i, 14).Value 'Oct CC amount after refresh
If Oct_TX <> 0 And Oct_CC = "" And ActiveSheet.Cells(21 + i, 2).Interior.Color = RGB(197, 217, 241) Then ' if TX is populated and CC is blank
ActiveSheet.Cells(21 + i, 14).Value = Oct_TX
End If
''Nov
Nov_TX = ActiveSheet.Cells(21 + i, 34).Value ' TX amount for Nov
Nov_CC = ActiveSheet.Cells(21 + i, 15).Value 'Nov CC amount after refresh
If Nov_TX <> 0 And Nov_CC = "" And ActiveSheet.Cells(21 + i, 2).Interior.Color = RGB(197, 217, 241) Then ' if TX is populated and CC is blank
ActiveSheet.Cells(21 + i, 15).Value = Nov_TX
End If
''Dec
Dec_TX = ActiveSheet.Cells(21 + i, 35).Value ' TX amount for Nov
Dec_CC = ActiveSheet.Cells(21 + i, 16).Value 'Dec CC amount after refresh
If Dec_TX <> 0 And Dec_CC = "" And ActiveSheet.Cells(21 + i, 2).Interior.Color = RGB(197, 217, 241) Then ' if TX is populated and CC is blank
ActiveSheet.Cells(21 + i, 16).Value = Dec_TX
End If