I have a project where I am populating and invoice template where the main body of the invoice has alternate lines that have a background colour of white and grey. Depending on the size / length of the invoice text, lines within the invoice are merged and then dependant on the invoice line count being odd / even, coloured accordingly. Unfortunately the code I'm using has no effect on the completed form (I've tried it without the code and it makes no difference), and I cannot see why the code is not actioning on the invoice!
Please can someone advise?
Many thanks
Steve
Please can someone advise?
Code:
xlInvoiceWorkSheet.Cells.Range("A" & StartingLineCount & ":A" & StartingLineCount + InvoiceDescLineCount - 1).MergeCells = True
xlInvoiceWorkSheet.Cells.Range("B" & StartingLineCount & ":B" & StartingLineCount + InvoiceDescLineCount - 1).MergeCells = True
xlInvoiceWorkSheet.Cells.Range("E" & StartingLineCount & ":E" & StartingLineCount + InvoiceDescLineCount - 1).MergeCells = True
xlInvoiceWorkSheet.Cells.Range("F" & StartingLineCount & ":F" & StartingLineCount + InvoiceDescLineCount - 1).MergeCells = True
MergeCount += 1
' Check if MergeCount is Odd / Even and set cell background colour
xlInvoiceWorkSheet.Range("A" & StartingLineCount & ":F" & StartingLineCount + InvoiceDescLineCount - 1).Select()
xlInvoiceWorkSheet.Cells.Range("F" & StartingLineCount).Activate()
If CLng(MergeCount) Mod 2 > 0 Then
With xlApp.Selection.Interior
.patterncolorindex = Excel.Constants.xlAutomatic
.ThemeColor = Excel.XlThemeColor.xlThemeColorDark1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else
With xlApp.Selection.Interior
.pattern = Excel.Constants.xlSolid
.patterncolorindex = Excel.Constants.xlAutomatic
.ThemeColor = Excel.XlThemeColor.xlThemeColorAccent3
.TintAndShade = 0.799981688894314
.PatternTintAndShade = 0
End With
End If
Many thanks
Steve