Также вам могут помочь следующие методы:
Function xlsRangeCopyConditionalFormat(ByRef r1 As Excel.Range, _
ByRef r2 As Excel.Range)
Dim i As Integer
For i = 1 To r1.FormatConditions.Count
r2.FormatConditions.Delete
Next
For i = 1 To r1.FormatConditions.Count
r2.FormatConditions.Add _
type:=r1.FormatConditions(i).type, _
Operator:=r1.FormatConditions(i).Operator, _
Formula1:=r1.FormatConditions(i).Formula1
xlsRangeCopyFont r1.FormatConditions(i).Font, r2.FormatConditions(i).Font
xlsRangeCopyInterior r1.FormatConditions(i).Interior, r2.FormatConditions(i).Interior
Next
End Function
Public Function xlsRangeCopyInterior(ByRef i1 As Excel.Interior, _
ByRef i2 As Excel.Interior)
With i2
.Pattern = i1.Pattern
.ColorIndex = i1.ColorIndex
End With
End Function
Public Sub xlsRepeatValueInCell(ByRef xlSheet As Excel.Worksheet, _
ByRef sColumn As String, _
ByVal irow As Integer, _
ByRef sValue As String)
xlsSetValueInCell xlSheet, sColumn, irow, sValue
xlSheet.Range(sfxls_RA1(sColumn, irow)).Borders(xlEdgeTop).color = RGB(255, 255, 255)
xlSheet.Range(sfxls_RA1(sColumn, irow)).Font.ColorIndex = 15
End Sub
Public Sub xlsSetCellInterior(ByRef xlSheet As Excel.Worksheet, _
ByRef sColumn As String, _
ByRef irow As Integer, _
ByRef iColorIndex As Integer, _
Optional ByRef bSetCellValue As Boolean = False, _
Optional ByRef iCellValueColor = Null)
' Set cells interior based on the passed arguments
Dim iPattern As Integer, iColorIndex As Integer, sValue As String
iPattern = xlSolid 'iPattern = xlGray16
xlSheet.Range(sfxls_RA1(sColumn, irow)).Interior.Pattern = iPattern
xlSheet.Range(sfxls_RA1(sColumn, irow)).Interior.ColorIndex = iColorIndex
If bSetCellValue = True Then
xlSheet.Range(sfxls_RA1(sColumn, irow)).FormulaR1C1 = sValue
End If
If Not IsNull(iCellValueColor) Then
xlSheet.Range(sfxls_RA1(sColumn, irow)).Font.ColorIndex = iCellValueColor
Else
xlSheet.Range(sfxls_RA1(sColumn, irow)).Font.ColorIndex = iColorIndex
End If
End Sub