简体   繁体   English

Excel VBA宏清除包含特定单元格的数据

[英]Excel VBA Macro's to clear data containing specific cell

I am trying to create an excel macro VBA to clear some specific cell (F4,H4,H5,H6,H7,F8,H8,F9,H9,H14) value and assigning the same macro to button. 我正在尝试创建一个Excel宏VBA,以清除某些特定的单元格(F4,H4,H5,H6,H7,F8,H8,F9,H9,H14)值,并将相同的宏分配给按钮。 But it's not working. 但这不起作用。 Could someone please help by correcting macro. 有人可以通过更正宏来提供帮助。

Sub Clear()
   Range("F4,H4,H5,H6,H7,F8,H8,F9,H9,H14").Clear
End Sub

Regards RKP 关于RKP

Thank you all for helping me with the code. 谢谢大家帮助我编写代码。 Below is the working code. 以下是工作代码。

Sub ClearContent() 子ClearContent()

Range("H5:I5").Select
Selection.ClearContents

Range("F7:I7").Select
Selection.ClearContents

Range("F8").Select
Selection.ClearContents

Range("H8:I8").Select
Selection.ClearContents

Range("H9:I9").Select
Selection.ClearContents

Range("F14:I14").Select
Selection.ClearContents

Range("F15:I15").Select
Selection.ClearContents

End Sub 结束子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM