VBA copy cells value and format

后端 未结 4 1543
北荒
北荒 2020-12-01 14:48

How can I amend the following code in order to copy not only the value but also the fonts style, e.g. bold or not bold. Thanks

Private Sub CommandButton1_Cli         


        
4条回答
  •  Happy的楠姐
    2020-12-01 15:10

    Found this on OzGrid courtesy of Mr. Aaron Blood - simple direct and works.

    Code:
    Cells(1, 3).Copy Cells(1, 1)
    Cells(1, 1).Value = Cells(1, 3).Value
    

    However, I kinda suspect you were just providing us with an oversimplified example to ask the question. If you just want to copy formats from one range to another it looks like this...

    Code:
    Cells(1, 3).Copy
        Cells(1, 1).PasteSpecial (xlPasteFormats)
        Application.CutCopyMode = False
    

提交回复
热议问题