메인 컨텐츠로 가기

 Excel에서 특정 셀을 지우는 단추를 적용하는 방법은 무엇입니까?

일반적으로 Ctrl 키 키를 눌러 여러 특정 셀을 선택한 다음 필요에 따라 셀 내용을 지 웁니다. 이러한 특정 셀을 항상 지워야하는 경우 한 번의 클릭으로 지우기 단추를 만들어 지울 수 있습니다. 이 기사에서는 일부 특정 셀 내용을 지우는 모두 지우기 단추를 만드는 방법에 대해 설명합니다.

VBA 코드로 특정 셀 내용을 지우는 버튼 적용


화살표 블루 오른쪽 거품 VBA 코드로 특정 셀 내용을 지우는 버튼 적용

먼저 모양 버튼을 만든 다음 코드를 적용하고 마지막으로 코드를 모양 버튼에 연결해야합니다. 다음과 같이하십시오 :

1. 딸깍 하는 소리 끼워 넣다 > 모양 > 직사각형 직사각형 모양을 선택한 다음 마우스를 드래그하여 필요한 시트의 아무 곳에 나 직사각형 버튼을 그립니다. 스크린 샷 참조 :

문서 버튼 지우기 셀 1

2. 그런 다음 텍스트를 입력하고 필요에 따라 모양 버튼의 서식을 지정합니다. 스크린 샷을 참조하십시오.

문서 버튼 지우기 셀 2

3. 그런 다음 VBA 코드를 삽입해야합니다. ALT + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창문. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창문.

VBA 코드 : 특정 셀에서 셀 내용 지우기 :

Sub Clearcells()
'Updateby Extendoffice
Range("A2", "A5").Clear
Range("C10", "D18").Clear
Range("B8", "B12").Clear
End Sub

주의 사항: 위 코드에서 : A2, A5 범위의 셀을 지울 것임을 나타냅니다. A2 : A5, 두 셀을 개별적으로뿐만 아니라 다음과 같이 여러 범위를 추가 할 수 있습니다. Range ( "B8", "B12"). 지우기 지울 코드 내의 스크립트.

4. 그런 다음 코드 창을 저장하고 닫은 다음 코드를 모양 버튼에 연결하고 버튼을 마우스 오른쪽 버튼으로 클릭 한 다음 매크로 지정,에 매크로 지정 대화 상자에서 클리어 셀 코드 이름 매크로 이름 목록 상자를 클릭하고 OK 버튼을 눌러이 대화 상자를 종료하십시오. 스크린 샷보기 :

문서 버튼 지우기 셀 3

5. 이제 클릭하면 모두 지우기 버튼을 클릭하면 정의한 특정 셀이 한 번에 지워집니다. 스크린 샷 참조 :

문서 버튼 지우기 셀 4

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
Comments (73)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
is there a way to delete data from multiple sheets with just 1 button?
This comment was minimized by the moderator on the site
Hello, Roya,
To clear the specific cells in multiple sheet, please apply the following vba code:
Sub ClearMultipleRanges()
    Dim ws As Worksheet
    Dim sheetsToClear As Variant
    Dim cellRanges As Variant
    Dim range As Variant

    sheetsToClear = Array("Sheet1", "Sheet2", "Sheet3") ' Change the sheet names
    cellRanges = Array("A1:C3", "E1:E5", "G1:G10") ' Modify the cell ranges
    For Each ws In ThisWorkbook.Sheets
        If Not IsError(Application.Match(ws.Name, sheetsToClear, 0)) Then
            For Each range In cellRanges
                ws.range(range).ClearContents
            Next range
        End If
    Next ws
End Sub


Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
is there a way to delete data from multiple sheets with just 1 button?
This comment was minimized by the moderator on the site
very helpful. thanks so much
This comment was minimized by the moderator on the site
Hi there,

Used this, and it works like a charm.

Only problem is... my cells are different formats... Some are 0,000 some are 00,00€ and when I it CLEAR, the format goes with tue clear event.

How can I clear the cells but maintain the format of them?
This comment was minimized by the moderator on the site
Hello, David,
To keep the cell formatting when clearing the cell contents, please apply the below code:
Sub ClearCellsKeepFormat()
    'Update by Extendoffice
    'This version clears the contents but keeps the cell formatting intact.
    Range("A2:A5").ClearContents
    Range("C10:D18").ClearContents
    Range("B8:B12").ClearContents
End Sub


Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
It worked. Thanks a lot man 😄
Rated 5 out of 5
This comment was minimized by the moderator on the site
Hi how do you use this macro without interfering the data validation?
This comment was minimized by the moderator on the site
I wanted that the confirmation needed for clear button .....so that the data is not cleared by mistakenly press the "clear" tab

And i wanted to say thanks for your brilliant work....thanks a lot in advance....

wish you have a great day...
This comment was minimized by the moderator on the site
Hello,
I am using this on one spreadsheet, but on 3 separate tabs. Everything was working last time I had the workbook open but today it is giving me an error "Ambiguous name detected: Clearcells". Please help!
This comment was minimized by the moderator on the site
Hallo zusammen,
hab soweit alles gemacht zu gewiesen usw. Funktioniert auch aber sobald ich die Datei öffne funktioniert es nicht mehr und muss alles neu eingeben.

Vorab vielen Dank
This comment was minimized by the moderator on the site
Meinte, nach dem schließen und dann wieder öffne.
This comment was minimized by the moderator on the site
Hi. I am trying to use a toggle button to clear all cells of color and text, but only the cells that contain the word “event”. And then I’d like to use the same toggle button to add the color and the word “event” back onto the spreadsheet. Can this be done?
This comment was minimized by the moderator on the site
Hallo,

Hoe kan ik cellen in een range met een formule intact houden met bovenstaand script?

Mvg,

Nol
This comment was minimized by the moderator on the site
Hello, Nol,
Do you mean to keep the formula cells when clearing the cell contents? Could you explain your problem by using English?

Thank you!
This comment was minimized by the moderator on the site
Hi Skyyang,

Thats what I mean indeed

Regards,

Nol
This comment was minimized by the moderator on the site
Hi, Nol,,
Maybe the follwoing VBA code can help you:
Sub Clearcells()
Dim xStr As String
Dim xRgs, xRg, xRgA As Range
xStr = "A2:C3,A5:E16,F5:H10"
Set xRgs = Range(xStr)
For Each xRgA In xRgs.Areas
    For Each xRg In xRgA
        If Not xRg.HasFormula Then
            xRg.Clear
        End If
    Next
Next
End Sub


Please change the cell references to your need, and you should use the comma to separate the data range.
Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Thanks Skyyang, the script works like an charm! Keep up the good work
This comment was minimized by the moderator on the site
Can you help me find a code that would clear the contents of merged cells but keep the formatting as well as formulas?
Thank you
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations