Note: The other languages of the website are Google-translated. Back to English
로그인  \/ 
x
or
x
회원가입  \/ 
x

or

 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


최고의 사무 생산성 도구

Excel 용 Kutools는 대부분의 문제를 해결하고 생산성을 80 % 향상시킵니다.

  • 재사용: 빠르게 삽입 복잡한 공식, 차트 그리고 이전에 사용한 모든 것; 셀 암호화 암호로; 메일 링리스트 생성 이메일 보내기 ...
  • 슈퍼 포뮬러 바 (여러 줄의 텍스트와 수식을 쉽게 편집 할 수 있습니다.) 레이아웃 읽기 (많은 수의 셀을 쉽게 읽고 편집합니다.) 필터링 된 범위에 붙여 넣기...
  • 셀 / 행 / 열 병합 데이터 손실없이; 셀 내용 분할; 중복 행 / 열 결합... 중복 셀 방지; 범위 비교...
  • 중복 또는 고유 선택 행; 빈 행 선택 (모든 셀이 비어 있음); 슈퍼 찾기 및 퍼지 찾기 많은 통합 문서에서; 무작위 선택 ...
  • 정확한 사본 수식 참조를 변경하지 않고 여러 셀; 참조 자동 생성 여러 시트에; 글 머리 기호 삽입, 확인란 등 ...
  • 텍스트 추출, 텍스트 추가, 위치 별 제거, 공간 제거; 페이징 부분합을 만들고 인쇄합니다. 셀 내용과 주석 간 변환...
  • 슈퍼 필터 (다른 시트에 필터 구성표 저장 및 적용) 고급 정렬 월 / 주 / 일, 빈도 등 특수 필터 굵은 기울임 꼴로 ...
  • 통합 문서와 워크 시트 결합; 키 열을 기반으로 테이블 병합; 데이터를 여러 시트로 분할; xls, xlsx 및 PDF 일괄 변환...
  • 300 개 이상의 강력한 기능. Office / Excel 2007-2019 및 365를 지원합니다. 모든 언어를 지원합니다. 기업 또는 조직에 쉽게 배포 할 수 있습니다. 전체 기능 30 일 무료 평가판. 60 일 환불 보장.
kte 탭 201905

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

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50 % 향상시키고 매일 수백 번의 마우스 클릭을 줄입니다!
officetab 하단
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Sarah · 7 months ago
    So it clears the data just fine and keeps the formatting, but then I lose all my formulas in the cells. Is there anyway to fix this so it just clears the number?
    It's for data entry of rating scales
  • To post as a guest, your comment is unpublished.
    king · 8 months ago
    How can you do this for check boxes so they also clear in addition to the fields?
  • To post as a guest, your comment is unpublished.
    Manyusli · 8 months ago
    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.
      Manyusli · 8 months ago
      This is a screenshot of my work sheet, sorry I'm not a expert in excel....
  • To post as a guest, your comment is unpublished.
    Monica · 8 months ago
    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.
    nate · 8 months ago
    i am trying to clear certain cells across several tabs. How can i accomplish this? I have built a checklist that is about 100 questions long on several tabs, and it is hard to go back and delete the feedback from every cell.
  • To post as a guest, your comment is unpublished.
    Robin · 1 years ago
    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.
    walaseyhk@gmail.com · 1 years ago
    Please give marco for clear if cell content less than 4 digital numbers. Thanks
  • To post as a guest, your comment is unpublished.
    jorge · 1 years ago
    when the command button I press delete it also deletes the continuous cells and I already have a formula in them and I don't want to delete those
  • To post as a guest, your comment is unpublished.
    Arshpreet · 1 years ago
    its not working
  • To post as a guest, your comment is unpublished.
    nocktys.fbm@gmail.com · 1 years ago
    How to do on Google Sheets please ?
  • To post as a guest, your comment is unpublished.
    Fabricio · 1 years ago
    It is not working on merged cells. :(
    • To post as a guest, your comment is unpublished.
      Penny · 1 years ago
      Try this,

      For example: The merged cells are columns A and B. You want to clear rows 2 thru 5. It'd look like the below.

      Sub Clearcells()
      Range("A2:B2", "A5:B5").ClearContents
      End Sub
    • To post as a guest, your comment is unpublished.
      taviodnw@gmail.com · 1 years ago
      replace .Clear by = ""
      • To post as a guest, your comment is unpublished.
        Kean Miller · 1 years ago
        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.
    ljmajik@gmail.com · 1 years ago
    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.
      Don · 1 years ago
      you can use = clear.


      for Eg.

      Range("A2", "A5") = Clear
  • To post as a guest, your comment is unpublished.
    Jennifer · 1 years ago
    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.
      skyyang · 1 years ago
      Hi, Jennifer,
      To clear only one cell, you just need to change the VBA code as this: (Note: change the cell A2 to the cell you want to clear)

      Sub Clearcells()
      Range("A2").Clear
      End Sub

      Please try, hope it can help you!
  • To post as a guest, your comment is unpublished.
    Radheshyam · 2 years ago
    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.
      skyyang · 2 years ago
      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.
    Stan · 2 years ago
    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.
      Nate · 8 months ago
      i have the same question

      • To post as a guest, your comment is unpublished.
        Christopher · 6 months ago
        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.
    Adnandos · 2 years ago
    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.
      OS · 2 years ago
      Hi, Put a button on top of row 3,6,7. Assign the same marco as above on each button to clear that particular row only.
  • To post as a guest, your comment is unpublished.
    basilrubber@gmail.com · 3 years ago
    This is clearing the border also, what can i do?
    • To post as a guest, your comment is unpublished.
      Jay · 2 years ago
      change clear to clearcontents then formatting will stay the same after clearing. only text will be gone not borders and colouring etc
  • To post as a guest, your comment is unpublished.
    ian · 3 years ago
    can you make this work over several sheets?
  • To post as a guest, your comment is unpublished.
    Piotr · 3 years ago
    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.
      Robert · 3 years ago
      Instead of the clear command, an example line from above would look like:
      Range("A2:A5") = 0
  • To post as a guest, your comment is unpublished.
    Ashleigh Bonner · 3 years ago
    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.
      Calvin Hodgson · 2 years ago
      Or, simply right-clicking the shape allows you to change formatting and text.
  • To post as a guest, your comment is unpublished.
    Steph · 3 years ago
    thank you!
  • To post as a guest, your comment is unpublished.
    ken besse · 3 years ago
    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.
      Adam · 3 years ago
      change the command from "clear" to "clearcontents" to just erase the text inputs
      • To post as a guest, your comment is unpublished.
        dsnyan · 2 years ago
        what about the color?
  • To post as a guest, your comment is unpublished.
    anand · 3 years ago
    GIVE FORMULAS FOR SAVE AND CLEAR