0

我正在尝试清除工作表上所有具有空白标题的列。

Set names = Sheets("Sheet2").Range(Sheets("Sheet2").Cells(1, 2), Sheets("Sheet2").Cells(1, 100))

For Each Cell In names
    If IsEmpty(Cell.Value) Then
    Cell.Columns.ClearContents
    End If
 Next Cell

除了代码运行之外,我没有看到任何变化。这里有逻辑错误吗?也许在这里:

    Cell.Columns.ClearContents
4

1 回答 1

1

尝试这个:

For Each cell In Names
    If IsEmpty(cell.Value) Then
        Dim col As Range
        Set col = cell.EntireColumn
        col.ClearContents
    End If
Next cell
于 2013-07-26T13:54:20.163 回答