2021年1月18日星期一

Code to copy formulas and values with offset on both

Here is the code I'm trying. When I try to use paste values I get the 1004 error.

Private Sub CommandButton1_Click()

Dim WB As Workbook Dim WS As Worksheet

Set WB = ThisWorkbook  Set WS = Sheets("CHART Data1")    With WS      If IsEmpty(.Range("E5").Offset(0, 1)) Then                   .Range("E5").Copy .Range("E5").Offset(0, 1)              Range("E5").Copy .Range("E5").Offset(0, 1).PasteSpecial(xlPasteValues, Operation:=xlNone)             Else          .Range("E5").End(xlToRight).Copy .Range("E5").End(xlToRight).Offset(0, 1)          End If  End With  

End sub

https://stackoverflow.com/questions/65785341/code-to-copy-formulas-and-values-with-offset-on-both January 19, 2021 at 12:07PM

没有评论:

发表评论