目的地:=只移动价值观?

时间:2014-04-07 19:51:31

标签: excel vba

如果有任何标记为是的话,我正在使用以下代码移动数据,但是,使用此代码也会移动任何数据验证等。在那里我可以得到以下工作,只放置单元格的值,在新工作表上保留原始数据验证等?我已经尝试了.value和使用.PasteSpecial,我目前卡住了。

  If Application.WorksheetFunction.CountIf(Range("G8:G101"), "Yes") >= 1 Then

    Selection.AutoFilter Field:=6, Criteria1:="Yes"
    Range("B8:F101").Copy Destination:=Sheet4.Range("B" & Rows.Count).End(xlUp).Offset(1)
    Range("H8:L101").Copy Destination:=Sheet4.Range("G" & Rows.Count).End(xlUp).Offset(1)
    Range("B8:K101").ClearContents
    Selection.AutoFilter Field:=6

1 个答案:

答案 0 :(得分:0)

请将原始代码发布为PasteSpecial确实有效。

反正:

'PasteSpecial method
'note: destination cells outside the original count will be unchanged
Range("B8:F101").Copy
Sheet4.Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues

'direct assignment method
'note: destination cells outside the original count will be overwritten with #N/A
Sheet4.Range("B" & Rows.Count).End(xlUp).Offset(1).Value = Range("B8:F101").Value
相关问题