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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -