[英]VBA clear data in sheet except first Row and Column G
谁能告诉我如何在不清除第一行和列G的情况下清除工作表的内容?
Voila! 瞧!
Range("A2:F" & Rows.Count).ClearContents
Range("H2", Cells(Rows.Count, Columns.Count)).ClearContents
you could use a SpecialCells() method flavor to act (ie ClearContents
) on visible cells only, as follows: 您可以使用SpecialCells()方法来
ClearContents
可见单元执行操作(即ClearContents
),如下所示:
Sub main()
HideMyFavorites True '<--| hide your favorite rows/columns
Cells.SpecialCells(xlCellTypeVisible).ClearContents '<--| clear the content of "visible" cells only
HideMyFavorites False '<--| unhide your favorite rows/columns
End Sub
Sub HideMyFavorites(doHide As Boolean)
Columns(7).Hidden = doHide '<--| hide/unhide column "G" (whose column index of "7")
Rows(1).Hidden = doHide '<--| hide/unhide row "1"
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.