excel - Copy sheet INCLUDING comments -
i looking copy sheet 1 workbook workbook is, including comments. far, have not found simple way this. code works copying , pasting contents of sheet workbook without comments:
sub copyorrefreshsheet(destwb workbook, sourcews worksheet) dim ws worksheet on error resume next set ws = destwb.worksheets(sourcews.name) on error goto 0 if ws nothing sourcews.copy after:=destwb.worksheets(destwb.worksheets.count) else ws.unprotect password:="abc123" ws.cells.clearcontents ws.range(sourcews.usedrange.address).value = sourcews.usedrange.value2 end if end sub
i sure take 1 line of code fix problem, not know how. thank in advance.
try change:
ws.range(sourcews.usedrange.address).value = sourcews.usedrange.value2
to:
sourcews.usedrange.copy ws.range(sourcews.usedrange.address).pastespecial(xlpasteall)
Comments
Post a Comment