# VBA，excel中选择特定内容复制粘贴

vba 专栏收录该内容
2 篇文章 0 订阅

sheet1

   A    |   B
id    |  公式列
001   |   20
002   |   11
003   |    0

sheet2原始

   A   |   B        |     C
id  |  公式列     |   数值列
004  |   12       |     12
005  |   17       |     17

sheet2宏后

   A     |   B         |     C
id    |  公式列      |   数值列
004    |   12        |     12
005    |   17        |     17
003    |    0        |      0

    Sheets("sheet1").Select
ActiveSheet.Range("$B$1:$B$10000").AutoFilter Field:=3, Criteria1:=0
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy

    Sheets("sheet2").Select
Range("A1").Select
Selection.End(xlDown).Select
Range("A" & Range("A1").End(xlDown).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


    Sheets("sheet2").Select
ROW1 = Range("A" & Rows.Count).End(xlUp).Row
Range("B2").Copy
Range("B2:B" & ROW1).PasteSpecial Paste:=xlPasteFormulas
Application.CutCopyMode = False


    Sheets("sheet2").Select
ROW2 = Range("C" & Rows.Count).End(xlUp).Row
Range(Cells(ROW2 + 1, 2), Cells(ROW1, 2)).Select
Selection.Copy
Range(Cells(ROW2 + 1, 3), Cells(ROW1, 3)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

• 8
点赞
• 2
评论
• 31
收藏
• 一键三连
• 扫一扫，分享海报

11-22

05-21
06-28 1万+
03-30 3270
08-28 1万+
05-29 1871
11-08 2万+
01-04 1万+
06-30 4万+
04-29 1136
10-28 4593