메인 컨텐츠로 가기

Excel 통합 문서에서 열기 및 종료시 지정된 셀 내용을 지우는 방법은 무엇입니까?

이 기사에서는 Excel 통합 문서를 열거 나 닫을 때 지정된 셀 내용을 지우는 방법에 대해 설명합니다.

통합 문서 열기 및 종료시 지정된 셀 내용 지우기


통합 문서 열기 및 종료시 지정된 셀 내용 지우기

통합 문서 열기 및 종료시 지정된 셀 내용을 지우려면 다음과 같이하십시오.

첫째, 열 때 지정된 셀 내용을 지우거나 종료해야하는 통합 문서를 Excel 매크로 사용 통합 문서로 저장해야합니다.

1. 클릭하십시오 입양 부모로서의 귀하의 적합성을 결정하기 위해 미국 이민국에 > 다른 이름으로 저장 > 검색. 스크린 샷보기 :

2. 에서 다른 이름으로 저장 대화 상자에서 통합 문서를 저장할 폴더를 선택하고 새 이름을 입력하십시오. 파일 이름 필요에 따라 상자를 선택하십시오. Excel 매크로 사용 통합 문서 인사말 유형으로서의 사바 드롭 다운 목록을 클릭 한 다음 찜하기 버튼을 클릭합니다.

3. 팝업에서 Microsoft Excel에서 대화 상자에서 OK 아래 스크린 샷과 같이 버튼을 클릭합니다.

4. 방금 저장 한 매크로 사용 통합 문서를 열고 다른 + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

5. 에서 응용 프로그램 용 Microsoft Visual Basic 창, 더블 클릭 이 워크북 왼쪽 창에서 VBA 코드 아래를 코드 창에 복사하십시오.

VBA 코드 1 : 통합 문서 열기에서 지정된 셀 내용 지우기

Private Sub Workbook_Open()
'Updated by Extendoffice 20190712
    Application.EnableEvents = False
        Worksheets("test").Range("A1:A11").Value = ""
    Application.EnableEvents = True
End Sub

VBA 코드 2 : 통합 문서 종료시 지정된 셀 내용 지우기

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Updated by Extendoffice 20190712
    Worksheets("test").Range("A1:A11").Value = ""
End Sub

주의 사항: 위 코드에서 test, A1 : A11은 내용을 지울 워크 시트 이름과 셀 범위입니다. 필요에 따라 변경하십시오.

6. 누르세요 다른 + Q 나가는 열쇠 응용 프로그램 용 Microsoft Visual Basic 창.

이제부터 통합 문서를 열거 나 닫을 때 특정 워크 시트의 지정된 셀 내용이 자동으로 지워집니다.


관련 기사 :

최고의 사무 생산성 도구

🤖 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 (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thank You Crystal! It works.

G
This comment was minimized by the moderator on the site
Dear Friends I tried the suggested code with no effect on open>

Private Sub Workbook_Open()


Application.EnableEvents = False

Worksheets("Clienti").Range("A9:K900").Value = ""

Application.EnableEvents = True

End Sub


The macro does work from within the workbook but not when the workbook opens.

Any help would be greatly appreciated!
This comment was minimized by the moderator on the site
Hi TUDOSE GELU,
The code works well in my case.
Don't forget to put the code in the ThisWorkbook (Code) window, and save the workbook as an Excel Macro-Enabled Workbook.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/2022-oct/oct-2.png
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/2022-oct/oct-1.png
This comment was minimized by the moderator on the site
Can someone help me how to blankout cells of sheet (only in a row and not entire Sheet). Below code removes contents in all rows of the sheet. But I want contents to be cleared only in row9



Private Sub Workbook_Open()

'Updated by Extendoffice 20190712

Application.EnableEvents = False

Worksheets("test").Range("A1:A11").Value = ""

Application.EnableEvents = True

End Sub
This comment was minimized by the moderator on the site
Hi,
The above VBA only clear the cell value of range A1:A11. If you want to clear only the values in row 9, you can replace A1:A11 with 9:9. See the below code.

Private Sub Workbook_Open()

'Updated by Extendoffice 20200522

Application.EnableEvents = False

Worksheets("test").Range("9:9").Value = ""

Application.EnableEvents = True

End Sub
This comment was minimized by the moderator on the site
Can someone help me how to blankout cells of sheet (only in a row and not entire Sheet). Below code removes contents in all rows of the sheet. But I want contents to be cleared only in row9

Private Sub Workbook_Open()

'Updated by Extendoffice 20190712

Application.EnableEvents = False

Worksheets("test").Range("A1:A11").Value = ""

Application.EnableEvents = True

End Sub
This comment was minimized by the moderator on the site
Hello, for the range how would I enter the code if I want to select multiple range or cells?
This comment was minimized by the moderator on the site
Dear sir/madam, my sheet is protected and only specified cell (for data clearing) is not protected but when i enter the value in the specified & then re-open the excel file then value is cleared by VBA code but the specified cell is protected, i have to un-protect cell by un-protecting the sheet edit the editable range again & again so please fix.
Thanks in advance
This comment was minimized by the moderator on the site
Hi Sanjay Sharma,
Sorry for the inconvinience. Please apply the below VBA codes and remember to replace the sheet name and the range to your needs. Thank you for your comment.

VBA code 1:
Private Sub Workbook_Open()
Application.EnableEvents = False
Worksheets("Sheet1").Range("A1:A11").Value = ""
Application.EnableEvents = True
End Sub

VBA code 2:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Worksheets("Sheet1").Range("A1:A11").Value = ""
End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations