vba excel如何仅在没有单元格格式的情况下粘贴值

时间:2018-05-03 12:09:48

标签: excel vba excel-vba

我尝试使用PasteSpecial,但它会抛出错误 - “预期结束语句”

有我的代码。 感谢

LastRow = sheet.Cells(sheet.Rows.Count, "B").End(xlUp).Row
sheet.Range("A2:S" & LastRow).Select

Selection.AutoFilter field:=2, Criteria1:=Array("PT"), Operator:=xlFilterValues
Selection.AutoFilter field:=1, Criteria1:=Array("AMD"), Operator:=xlFilterValues

Selection.AutoFilter field:=4, Criteria1:=Array("201701", "201702", "201703", "201704", "201705", "201706", "201707", "201708", "201709", "201710", "201711", "201712", "201801", "201802", "201803"), Operator:=xlFilterValues

Set rng = sheet.Range("A3:A" & LastRow, "B3:B" & LastRow)

rng.SpecialCells(xlCellTypeVisible).Copy MasterWs.Range("A" & Rows.Count, "B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues

1 个答案:

答案 0 :(得分:0)

尝试用你的最后一行代码交换:

rng.SpecialCells(xlCellTypeVisible).Copy
MasterWs.Range("A" & Rows.Count, "B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues