excel vba单元按列提取内容

单元按列A:I列提取内容
2025-03-18 15:23:56
推荐回答(2个)
回答1:

以下代码及注释为将A列中等于1的单元格,提取到B列中:
Sub main()
Dim i%
For i = 1 To Range("A65536").End(3).Row 'i从1到A列最后一个非空单元格的行号循环
If Cells(i, "A").Value = 1 Then '如果A列的值为1
Cells(i, "B") = Cells(i, "A") '则B列对应单元格的值等于A列的值
End If
Next i
End Sub

回答2:

Sub s()
ceto = 2
t = Cells(Rows.Count, ceto).End(3)
n = Cells(Rows.Count, 11).End(3).Row
For i = 11 To 353
If Cells(n, i) < 7 Then
If Cells(n, i) + 3 = Cells(n - 1, i) Then Cells(1, i) = t
ElseIf Cells(n, i) = 9 Then
If Cells(n - 1, i) = 0 Then Cells(1, i) = t
Else
If Cells(n, i) - 6 = Cells(n - 1, i) Then Cells(1, i) = t
End If
Next
End Sub