Dim oExcel As New Excel.Application
Dim oWorkbook As Excel.Workbook = oExcel.Workbooks.Add
Dim oWorksheet As Excel.Worksheet = CType(oWorkbook.Worksheets(1), _
Excel.Worksheet)
Dim lExcelRow As Long
Dim sRangeText As String
Dim oRange As Excel.Range
Dim oFormatCond1 As Excel.FormatCondition
Dim oFormatCond2 As Excel.FormatCondition
Dim oFormatCond3 As Excel.FormatCondition
...
oRange = CType(.Range("P2:P" & lExcelRow), Excel.Range)
oRange.Select()
oRange.FormatConditions.Delete()
'*********Code bombs on next line***************
oFormatCond1 = CType(oWorksheet.Range(oRange).FormatConditions.Add( _
Type:=Excel.XlFormatConditionType.xlCellValue, _
Operator:=Excel.XlFormatConditionOperator.xlBetween, Formula1:="0.49", Formula2:="0.66"), Excel.FormatCondition)
CType(oFormatCond1.Interior, Excel.Interior).ColorIndex = 50
oFormatCond2 = CType(oRange.FormatConditions.Add( _
Type:=Excel.XlFormatConditionType.xlCellValue, _
Operator:=Excel.XlFormatConditionOperator.xlLess, _
Formula1:="0.49"), Excel.FormatCondition)
CType(oFormatCond2.Interior, Excel.Interior).ColorIndex = 15
oFormatCond3 = CType(oRange.FormatConditions.Add( _
Type:=Excel.XlFormatConditionType.xlCellValue, _
Operator:=Excel.XlFormatConditionOperator.xlGreater, _
Formula1:="1"), Excel.FormatCondition)
CType(oFormatCond2.Interior, Excel.Interior).ColorIndex = 15
...
|