Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 1004 Application -defined or object -defined error

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I am trying to apply conditional formatting to an Excel 2003 spreadsheet from Access 2003. I keep on getting this runtime error 1004. I was hoping to get some assistance.
The failure is highlighted in Blue
Tom

Code:
    iColor1 = 36
    iColor2 = 40
    '*************************************************************************************
    '*****************    First Condition Columns G and H   ******************************
    '*************************************************************************************
    goXl.Range("G7:H" & intLastRow).Select
    'Color Index 36 = Yellow
    goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="-0.15", Formula2:="-0.25"
    goXl.Selection.FormatConditions(1).Interior.ColorIndex = iColor1
    'Color Index 44 = goXl.Range
    goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLessEqual, _
        Formula1:="-0.25"
    goXl.Selection.FormatConditions(2).Interior.ColorIndex = iColor2
    '***********************************************************************************
    '********************   Second Condition  Column H *********************************
    '***********************************************************************************
    goXl.Range("K7:K" & intLastRow).Select
    'Color Index 36 = Yellow
    goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="50", Formula2:="60"
    goXl.Selection.FormatConditions(1).Interior.ColorIndex = iColor1
    goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="60"
    goXl.Selection.FormatConditions(2).Interior.ColorIndex = iColor2
    '***********************************************************************************
    '********************   Third Condition   ******************************************
    '***********************************************************************************
    
    goXl.Range("L7:L" & intLastRow).Select
     'Color Index 36 = Yellow
    goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="0.2", Formula2:="0.3"
    goXl.Selection.FormatConditions(1).Interior.ColorIndex = iColor1
   [Blue] goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
        , Formula1:="0.3" [/Blue]
    goXl.Selection.FormatConditions(2).Interior.ColorIndex = iColor2
    '**********************************************************************************
    '*************************  Fourth Condition    ***********************************
    '**********************************************************************************
    goXl.Range("M7:M" & intLastRow).Select
     'Color Index 36 = Yellow
    goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="-100000", Formula2:="-200000"
    goXl.Selection.FormatConditions(1).Interior.ColorIndex = iColor1
     'Color Index 36 = Yellow
    goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="100000", Formula2:="200000"
    goXl.Selection.FormatConditions(1).Interior.ColorIndex = iColor1
    'Color Index 44 = OgoXl.Range
    goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
        Formula1:="-200000"
    goXl.Selection.FormatConditions(1).Interior.ColorIndex = iColor2
    goXl.Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
        Formula1:="200000"
    goXl.Selection.FormatConditions(2).Interior.ColorIndex = iColor2
    



/[code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top