ボタンを適用してExcelの特定のセルをクリアするにはどうすればよいですか?
通常、あなたは保持することができます Ctrlキー キーを押して複数の特定のセルを選択し、必要に応じてセルの内容をクリアします。 これらの特定のセルを時々クリアする必要がある場合は、クリアボタンを作成してワンクリックでそれらをクリアできます。 この記事では、特定のセルの内容をクリアするために[すべてクリア]ボタンを作成する方法について説明します。
ボタンを適用して、VBAコードで特定のセルの内容をクリアします
ボタンを適用して、VBAコードで特定のセルの内容をクリアします
まず、シェイプボタンを作成してからコードを適用し、最後にコードをシェイプボタンに結び付けます。 次のようにしてください。
1に設定します。 OK をクリックします。 インセット > 形状 > 長方形 長方形の形状を選択し、マウスをドラッグして、必要に応じてシートの任意の場所に長方形のボタンを描画します。スクリーンショットを参照してください。
2。 次に、テキストを入力し、必要に応じてシェイプボタンをフォーマットします。スクリーンショットを参照してください。
3。 次に、VBAコードを挿入する必要があります。 Alt + F11 キーを押して Microsoft Visual Basic for Applications 窓。 クリック インセット > モジュール、次のコードをに貼り付けます モジュール 窓。
VBAコード:特定のセルからセルの内容をクリアします。
Sub Clearcells() 'Updateby Extendoffice Range("A2", "A5").Clear Range("C10", "D18").Clear Range("B8", "B12").Clear End Sub
ノート:上記のコードでは: A2、A5 範囲内のセルをクリアすることを示します A2:A5、XNUMXつのセルを個別に追加するだけでなく、次のような複数の範囲を追加できます。 Range( "B8"、 "B12")。Clear クリアするコード内のスクリプト。
4。 次に、コードウィンドウを保存して閉じ、コードを図形ボタンにリンクし、ボタンを右クリックして、を選択します。 マクロの割り当て、で マクロの割り当て ダイアログボックスで、 クリアセル からのコードネーム マクロ名 リストボックスをクリックし、 OK ボタンをクリックして、このダイアログを終了します。 スクリーンショットを参照してください:
5。 そして今、あなたがクリックすると すべてをクリア ボタンをクリックすると、定義した特定のセルが一度にクリアされます。スクリーンショットを参照してください。
最高のオフィス生産性ツール
Kutools for Excelはほとんどの問題を解決し、生産性を80%向上させます
- 再利用: すばやく挿入 複雑な数式、チャート および以前に使用したものすべて。 セルを暗号化する パスワード付き。 メーリングリストを作成する そしてメールを送る...
- スーパーフォーミュラバー (複数行のテキストと数式を簡単に編集できます); 読書レイアウト (多数のセルを簡単に読み取って編集する); フィルター範囲に貼り付け...
- セル/行/列をマージする データを失うことなく; 分割セルコンテンツ; 重複する行/列を組み合わせる...重複セルを防止します。 範囲を比較する...
- [複製]または[一意]を選択します 行; 空白行を選択 (すべてのセルは空です); スーパーファインドとファジーファインド 多くのワークブックで; ランダム選択...
- 正確なコピー 数式参照を変更せずに複数のセル。 参照の自動作成 複数のシートに; 箇条書きを挿入、チェックボックスなど...
- テキストを抽出、テキストの追加、位置による削除、 スペースを削除する; ページング小計の作成と印刷。 セルの内容とコメントを変換する...
- スーパーフィルター (フィルタースキームを保存して他のシートに適用します); 高度な並べ替え 月/週/日、頻度など。 特殊フィルター 太字、斜体...
- ワークブックとワークシートを組み合わせる; キー列に基づいてテーブルをマージします。 データを複数のシートに分割; xls、xlsx、PDFをバッチ変換...
- 300以上の強力な機能。 Office / Excel2007-2019および365をサポートします。すべての言語をサポートします。 企業や組織に簡単に導入できます。 全機能30日間の無料トライアル。 60日間の返金保証。

Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作業をはるかに簡単にします
- Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
- 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
- 生産性が50%向上し、毎日何百ものマウスクリックが減ります。

You are guest
or post as a guest, but your post won't be published automatically.
-
To post as a guest, your comment is unpublished.· 1 years agoIt celar everything including the border lines and Cells format, I want to clear the Data only.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.SUPER HELPFUL! THANK YOU.
But I have another question, maybe you can help me, in order to create the Clear cell macro button, and I already did it, and it just work perfectly. But I need to protect the sheet to make sure nobody delete important formulas, but it turns that this action make the clearcell macro button unclickble.......
What can I do in this case? Help please..... -
To post as a guest, your comment is unpublished.SUPER HELPFUL! THANK YOU.
But I have another question, maybe you can help me, in order to create the Clear cell macro button, and I already did it, and it just work perfectly. But I need to protect the sheet to make sure nobody delete important formulas, but it turns that this action make the clearcell macro button unclickble.......
What can I do in this case? Help please..... -
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hi! Works great for me with this code as you mentioned:
Sub Clearcells()
Range("A2", "A5").ClearContents
Range("C10", "D18").ClearContents
Range("B8", "B12").ClearContents
End Sub
However, I want to keep the number "0" or the procentage "0" for certain cells. Also, keep the previous selected colour. The reson for this is I use these cells as input cells and want to use the buttom to clear certin input cells.
Thanks in advance! -
To post as a guest, your comment is unpublished.Please give marco for clear if cell content less than 4 digital numbers. Thanks
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.How to do on Google Sheets please ?
-
To post as a guest, your comment is unpublished.It is not working on merged cells. :(
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.replace .Clear by = ""
-
To post as a guest, your comment is unpublished.For merged cells do you mean have the formatting for example be Range("A25","B25","C25")="" ?
-
-
-
To post as a guest, your comment is unpublished.Is there a way for me to keep the data validation list drops on the cells. For example my list drop includes Yes or No and I would like to reset the cells to blank but keep my data validation in the background
-
To post as a guest, your comment is unpublished.Hi,
What code do I use if I only need to clear one single cell instead of a range of cells? -
To post as a guest, your comment is unpublished.simply I did same in worksheet it worked when I protect the sheet it shows error 1004, any suggestion in this case?
-
To post as a guest, your comment is unpublished.Hi, Radheshyam,
To run above code in a protect worksheet, please apply the below code: (Note: change the text "password" to the password which protect your sheet)
Sub ClearcellsAsProtect()
Dim xWS As Worksheet
Dim xPsw As String
Set xWS = ActiveSheet
xPsw = "password"
On Error Resume Next
xWS.Unprotect Password:=xPsw
Range("A2", "A5").Clear
Range("C10", "D18").Clear
Range("B8", "B12").Clear
xWS.Protect Password:=xPsw
End Sub
Please try, hope it can help you!
-
-
To post as a guest, your comment is unpublished.I have a workbook with 11 tabs, plus one at the beginning marked as "Start Here". I want to create one button in that tab that will clear up to 9 individual cells of it's contents, or enter a "0" in it within each of these tabs. The cells I want to clear do not necessarily reside in the same spot on each page. Is this possible and how is it done? I presume this can be done in VisualBasic, but would it be easier for a neophyte to create it using Macros?
-
To post as a guest, your comment is unpublished.i have the same question
-
To post as a guest, your comment is unpublished.Use this as a script template:Sub Clearcells()
'Updateby Extendoffice 20161008
Range("b11:d22").ClearContents 'this line refers to the page with the macro button.
Range("'Eval Score Entry'!D2:AA2").ClearContents 'this line refers to a different tab and range.
End Sub
-
-
-
To post as a guest, your comment is unpublished.Hi. What is the best way to create seperate buttons to clear the contents of each row separately? eg data capturer is happy with the inputs of every other row, but then needs to clear rows 3, row 6 and row 7. What's the most efficient way to create buttons to clear in this way, ie row only?
-
To post as a guest, your comment is unpublished.This is clearing the border also, what can i do?
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Thx for this code. How to clear cell contents or ideally fill it up with 0 value in a protected sheet with just few editable cells? Thx for help on ot.
-
To post as a guest, your comment is unpublished.Thank you so much for this information!!
Another tip: I added a textbox. To combine the textbox with the shape, I selected the textbox, held down SHIFT, and then selected the shape. With those both selected I right-clicked and selected GROUP, then GROUP, again.
When these are grouped, you can still change the text and other formatting.
To ungroup, just right-click your new button and select GROUP > UNGROUP.-
To post as a guest, your comment is unpublished.Or, simply right-clicking the shape allows you to change formatting and text.
-
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.This also clears any formatting of the cell. How doI do this if I wantto keep formulas and formatting suchace as shading or borders
-
To post as a guest, your comment is unpublished.