excel vba在固定范围内,删除列内容

2025-02-24 14:40:53
推荐回答(3个)
回答1:

颜色分两种
一种 是常规填充的
一种 是条件格式返回的

如果是条件格式返回的,难度比较大
两种都是用VBA来做

回答2:

如下:

Sub 宏1()
Dim i As Integer, j As Long
For i = 70 To 11 Step -1
    For j = 1 To 65536
        If Cells(j, i).Interior.ColorIndex <> -4142 Then ' ±³¾°µÄÑÕɫΪÎÞÉ«
            Range(Cells(1, i), Cells(4, i)).Select
            Selection.Delete Shift:=xlToLeft
            Exit For
        End If
    Next
Next
End Sub

回答3:

如下:

Sub 宏1()
Dim i As Integer, j As Long
For i = 70 To 11 Step -1
    For j = 1 To 65536
        If Cells(j, i).Interior.ColorIndex <> -4142 Then 
            Range(Cells(1, i), Cells(4, i)).Select
            Selection.Delete Shift:=xlToLeft
            Exit For
        End If
    Next
Next
End Sub