vba選擇性粘貼為數(shù)值并判斷行數(shù)
求高手寫個(gè)宏,,把表格1的內(nèi)容選擇性粘貼為數(shù)值到表格2的D2開始,,表格2存在數(shù)據(jù),,被覆蓋粘貼后,判斷粘貼的行數(shù),,如果大于原來的數(shù)據(jù)行,,A-C列公式下拖,如果小于原來的數(shù)據(jù)行,,多出的原數(shù)據(jù)行刪除,。
Sub biao1TObiao2()
Sheets("Sheet1").Select
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
n1 = Selection.Rows.Count + 1
Selection.Copy
Sheets("Sheet2").Select
n2 = Application.CountA(Range("A:A"))
Range("D2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
If n1 > n2 Then
Range("A" & n2 & ":C" & n2).Select
Selection.AutoFill Destination:=Range("A" & n1 & ":C" & n2)
End If
If n1 < n2 Then Range(n1 + 1 & ":" & n2).Delete
End Sub
這個(gè)宏不是一兩句能寫好的,而且還要有表格數(shù)據(jù)參照,,你把文件發(fā)我微信lrz19991上,,我寫好宏再傳回給你。