如何仅在Excel中粘贴值 [英] how to paste only values in excel

查看:249
本文介绍了如何仅在Excel中粘贴值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常喜欢Excel,并且是全新的这个论坛。



我已经从下面的论坛中获取了代码,并根据需要进行了修改。 p>

http://pressf1.pcworld.co.nz/showthread.php?90122-Creating-Macro-to-copy-and-paste-data-into-下一个空列

  Sub copyTotals()
Dim TargetSht As Worksheet,SourceSht As Worksheet,SourceRow As Integer,SourceCells As Range
Set SourceSht = ThisWorkbook.Sheets(DUN - Jan)
Set TargetSht = ThisWorkbook.Sheets(DUN Jan - Jan ,Feb,Mar,Apr)
设置SourceCells = SourceSht.Range(L36,N36)
如果TargetSht.Range(C11)。Value =然后
SourceRow = 1
ElseIf TargetSht.Range(C41)< 然后
MsgBox(工作表已满,您需要创建一个新的工作表)
Else
SourceRow = TargetSht.Range(C41)。End(xlUp).Row + 1
如果

SourceCells.Copy TargetSht.Cells(SourceRow,3)
End Sub

问题是粘贴的值已经形成了源代码,我只想粘贴这些值。



可以有人请帮助我。

解决方案

将.Copy与.PasteSpecial一起使用。而不是:

  SourceCells.Copy TargetSht.Cells(2,SourceCol)
/ pre>

执行此操作:

  SourceCells.Copy 
TargetSht.Cells(2,SourceCol).PasteSpecial xlPasteValues


I'm quite new to Excel and completely new to this forum.

I have taken the code from the below forum and modified it to my need.

http://pressf1.pcworld.co.nz/showthread.php?90122-Creating-Macro-to-copy-and-paste-data-into-the-next-empty-column.

Sub copyTotals()
    Dim TargetSht As Worksheet, SourceSht As Worksheet, SourceRow As Integer, SourceCells As Range
    Set SourceSht = ThisWorkbook.Sheets("DUN - Jan")
    Set TargetSht = ThisWorkbook.Sheets("DUN Jan - Jan,Feb,Mar,Apr")
    Set SourceCells = SourceSht.Range("L36,N36")
    If TargetSht.Range("C11").Value = "" Then
        SourceRow = 1
    ElseIf TargetSht.Range("C41") <> "" Then
        MsgBox ("The sheet is full, you need to create a new sheet")
    Else
        SourceRow = TargetSht.Range("C41").End(xlUp).Row + 1
    End If

    SourceCells.Copy TargetSht.Cells(SourceRow, 3)
End Sub

The problem is that the values pasted have the formating of the source and i only want to paste the values.

Can someone please help me with this.

解决方案

Use .Copy together with .PasteSpecial. Instead of:

SourceCells.Copy TargetSht.Cells(2, SourceCol)

Do this:

SourceCells.Copy
TargetSht.Cells(2, SourceCol).PasteSpecial xlPasteValues

这篇关于如何仅在Excel中粘贴值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆