Excel 2003 to 2010 VBA Migration Error

dariuzthepole

Board Regular
Joined
Jul 23, 2008
Messages
111
Hi,

We've recently upgraded to Office 2010 and some locally stored macros are causing issues. This one is regarding a conditional formatting macro after importing data from an XML file. The code is below:

Code:
Sub Macro3()'


    Range( _
        "C9,E9,G9,I9,L9,O9,C13,E13,G13,I13,L13,O13,C14,E14,G14,I14,L14,O14,C17,E17,G17,I17,L17,O17,C19,E19,G19,I19,L19,O19,C24,E24,G24,I24,L24,O24" _
        ).Select
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="19.9", Formula2:="24.9"
'    With Selection.FormatConditions(1).Font
'        .Bold = False
'        .Italic = False
'    End With
    Selection.FormatConditions(1).Interior.ColorIndex = 6
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="25", Formula2:="29.9"
'    With Selection.FormatConditions(2).Font
'        .Bold = True
'        .Italic = False
'    End With
    Selection.FormatConditions(2).Interior.ColorIndex = 45
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="30", Formula2:="150"
'    With Selection.FormatConditions(3).Font
'        .Bold = True
'        .Italic = False
'    End With
    Selection.FormatConditions(3).Interior.ColorIndex = 3
End Sub

The With... commands have been commented out as the .Italic function is creating an error, causing the process to End/Debug.

This is one of several identical nested macros for several regions; the first two work with the .Italic reference active, but the remaining do not (example above).

Any help you could provide would be greatly appreciated!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I have also experienced "conditional formatting" issue after migration from 2003 to 2010. In my case I have to manually delete some condiional formatting created with excel 2003 and then apply it again in the excel 2010 environment. (Home >Conditional Formatting >Manage Rules >Edit Rule or Delete Rule).
 
Upvote 0

Forum statistics

Threads
1,216,569
Messages
6,131,466
Members
449,652
Latest member
ylsteve

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top