4/8/15:
objExcel.Cells(1, 1).Value = "Name"
objExcel.Cells(1, 1).Font.Bold = TRUE
objExcel.Cells(1, 1).Interior.ColorIndex = 30
objExcel.Cells(1, 1).Font.ColorIndex = 2
'List excel colors
For i = 1 to 56
objExcel.Cells(i, 1).Value = i
objExcel.Cells(i, 1).Interior.ColorIndex = i
Next
' Clear and ClearContent
Range("X").Cells.Clear ' this will clear the content along with background color
Range("X").Cells.ClearContents ' clears only content
Note: Remember “.Clear” will clear the everything from the cell right from cell data to cell formatting, borders etc.
If you just want to clear the content or data of the cells without effecting the format and border of the cell use “.ClearContents”
mainworkBook.Sheets(“MyFirstMacro”).Range(“C6”).ClearContents
No comments:
Post a Comment