如何复制xlCellTypeVisible单元格并保持其格式(粗体文本)?



我正在使用这段代码来复制和粘贴一些东西:

.SpecialCells(xlCellTypeVisible).Copy
Wsh.Cells(1).PasteSpecial Paste:=8
Wsh.Cells(1).PasteSpecial Paste:=xlPasteAll
Wsh.Cells(1).PasteSpecial Paste:=xlPasteFormats

但是,当它粘贴时,它会丢失格式。我正在复制的一些文本是粗体的,我希望它保持粗体。我怎样才能做到这一点?

尝试直接复制到目的地,然后返回并拾起留下的列宽。

with .SpecialCells(xlCellTypeVisible)
.copy destination:=Wsh.Cells(1)
.copy
Wsh.Cells(1).PasteSpecial Paste:=xlPasteColumnWidths
end with

最新更新