我希望有一个宏,它可以根据列标题删除特定列中的行范围。更具体地说,假设在第5行标记为“ C”的任何列,我想通过循环B至CB来清除那些特定列的第11至33行的内容。谢谢!
示例:
Sub Hide_Columns_Containing_Value()
'Description: This macro will loop through a row and
'hide the column if the cell in row 1 of the column
'has the value of C.
'Author: Jon Acampora, Excel Campus
Dim c As Range
For Each c In Range("A5:CE5").Cells
If c.Value = "C" Then
c.EntireColumn.Hidden = True {{{<------would like to clear contents of rows 11 thru 33 instead of hide columns}}}
End If
Next c
End Sub
答案 0 :(得分:0)
几个选项,以下是使用Intersect
的一个选项:
Intersect(c.EntireColumn, Rows("11:33")).ClearContents