excel 宏制作的问题 VB高手来帮帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/14 13:11:27
例如这样一张表格
A B C D
1 11 12 33 33
2 11 14 22 34
3 23 12 53 62
4 11 12 44 55
5 34 54 31 34
6 23 33 45 44

我需要筛选A列等于11的数据 然后将C 列的数值全部复制到另一张工作表
我想用宏实现这个动作 有没有高手可以帮忙写下VB 语句

同样的问题再增加一个条件列如 我要筛选A列等于11 且B等于12的数据怎么写VB 语句

录制一个宏不就行了!
Sub Macro1()
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:="11"
Range("C1:C4").Select
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste
Sheets("Sheet1").Select
Selection.AutoFilter Field:=2, Criteria1:="12"
End Sub

Sub ghj()

Dim i As Integer, j As Integer, k As Integer
j = 1
For i = 1 To Range("a65536").End(xlUp).Row
If Cells(i, 1).Value = 11 Then
Cells(j, 5).Value = Cells(i, 3).Value
j = j + 1
End If
Next i
End Sub

第二个

Sub ghj()

Dim i As Integer, j As Integer, k As Integer
j = 1
For i = 1 To Range("a65536").End(xlUp).Row
If Cells(i, 1).Value = 11 Then
If Cells(i, 2