Hello i have an Excel table with some formats 10(Red) -> 15(Green), but at the end I loose all the formats i have in my excel. I use the ne
While OP's accepted answer may have worked for him, I don't believe it's the right answer.
If you want to keep the formatting from your source you need to use xlPasteAllUsingSourceTheme
Code:
With TempWB.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
'.Cells(1).PasteSpecial xlPasteValues, , False, False
'.Cells(1).PasteSpecial xlPasteFormats, , False, False
.Cells(1).PasteSpecial xlPasteAllUsingSourceTheme, , False, False
.Cells(1).Select
Application.CutCopyMode = False
On Error Resume Next
.DrawingObjects.Visible = True
.DrawingObjects.Delete
On Error GoTo 0
End With
Ok I found how to made it, in rangetoHtml(), when is pasting the values I changed the code for:
With TempWB.Sheets(1)
'.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial
'.Cells(1).PasteSpecial xlPasteValues, , False, False
'.Cells(1).PasteSpecial xlPasteFormats, , False, False
'.Cells(1).Select
Application.CutCopyMode = False
On Error Resume Next
.DrawingObjects.Visible = True
.DrawingObjects.Delete
On Error GoTo 0
End With
Becase If I made just a copy and paste I dont lost any format.