I have a column 'A' in worksheet 'two' and another column 'B' in worksheet 'one' !
I want to copy the conditional formatting of Column A in two to Column B in one !
Basically, I want to copy everything from Column A in two to Column B in one except the data !
Please help !!
I have :
sheetA & sheetB obj开发者_运维知识库ect as Objects in my code
I am using VB.NET
I am a newbie in Vb.net - Please Help !
Here's a bit of a push:
oExcel = CreateObject("Excel.Application")
Book = oExcel.Workbooks.Open("C:\Users\Jonathan\Documents\Test2.xlsx")
Sheet = Book.Worksheets(1)
SourceRange = Sheet.Range("A1:A" & Sheet.Range("A1").End(Excel.XlDirection.xlDown).Row)
DestRange = Sheet.Range("D1:D" & Sheet.Range("D1").End(Excel.XlDirection.xlDown).Row)
The meat of it is this part, where you take the format conditions from one range and add it to the other. This assumes there is only one criterion for formatting. More than one would require that you would step over all of them (I think there are up to 3) by using SourceRange.FormatConditions(i) in a loop from 1 to SourceRange.FormatConditions.Count
DestRange.FormatConditions.Add(Excel.XlFormatConditionType.xlCellValue, SourceRange.FormatConditions(1).Operator, SourceRange.FormatConditions(1).Formula1)
DestRange.FormatConditions(1).Interior.ColorIndex = SourceRange.FormatConditions(1).Interior.ColorIndex
精彩评论