Copy and paste format including colour of cells VBA Excel

后端 未结 1 1732
花落未央
花落未央 2021-01-25 02:29
wbTarget.Sheets(\"Sheet1\").Range(\"A1:W79\").Value = wb.Sheets(wsSource.Name).Range(\"A1:W79\").Value

I have this code which works pasting the values

1条回答
  •  清歌不尽
    2021-01-25 03:12

    You need to use Copy, and PasteSpecial xlValues and PasteSpecial xlFormats.

    ' Copy
    wb.Sheets(wsSource.Name).Range("A1:W79").Copy
    ' Paste Special
    wbTarget.Sheets("Sheet1").Range("A1:W79").PasteSpecial xlValues
    wbTarget.Sheets("Sheet1").Range("A1:W79").PasteSpecial xlFormats
    

    Read about Range.PasteSpecial here MSDN

    0 讨论(0)
提交回复
热议问题