메인 컨텐츠로 가기

Excel에서 명령 단추로 (현재) 날짜 및 시간을 업데이트하거나 삽입하는 방법은 무엇입니까?

일반적으로 많은 Excel 사용자는 = NOW () 수식을 사용하여 타임 스탬프를 삽입하는 경향이 있습니다. 이 수식을 사용하면 삽입 된 타임 스탬프가 통합 문서를 열 때마다 자동으로 업데이트됩니다. 언제든지 워크 시트의 날짜와 시간을 수동으로 업데이트하려면 어떻게해야합니까? 이 기사에서는 Excel에서 명령 단추를 클릭하여 현재 날짜와 시간을 업데이트하는 방법을 보여줍니다.

VBA 코드로 명령 단추로 날짜 및 시간 업데이트


VBA 코드로 명령 단추로 날짜 및 시간 업데이트

Excel의 Command Button으로 날짜와 시간을 업데이트하려면 다음과 같이하십시오.

1. 클릭하여 명령 단추 삽입 개발자 > 끼워 넣다 > 명령 단추 (ActiveX 컨트롤). 스크린 샷보기 :

2. 삽입 된 명령 단추를 마우스 오른쪽 단추로 클릭 한 다음 코드보기 오른쪽 클릭 메뉴에서.

3. 팝업에서 응용 프로그램 용 Microsoft Visual Basic 창에서 원래 코드를 아래 VBA 코드로 바꾸십시오.

VBA 코드 : Excel의 명령 단추로 날짜 및 시간 업데이트

Private Sub CommandButton1_Click()
    Range("A2").Value = Now()
End Sub

주의 사항: 코드에서 CommandButton1은 삽입 된 Command Button의 이름입니다. A2는 업데이트 날짜와 시간이 표시되는 셀입니다. 필요에 따라 변경하십시오.

4. 개발자 탭에서 디자인 모드를 끕니다. 명령 단추를 클릭하면 현재 날짜와 시간이 A2 셀에 삽입됩니다.

그리고 명령 버튼을 클릭 할 때마다 A2 셀의 날짜와 시간이 즉시 업데이트됩니다.


관련 기사:

최고의 사무 생산성 도구

🤖 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 (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
How do i update the code to put the time/date stamp in the cell NEXT to the button so it applies to each row thereon
This comment was minimized by the moderator on the site
I have a question. There is a workbook that we keep on a share drive for the whole team to access. I want to add this macro to it so anytime changes are made, we can simply pres the button and the time and date will auto populate at a click. Now here is the question, from this workbook, data is pulled to other workbooks if I save a new file as "Macro-Enabled" and delete the old "Non-Macro" workbook, will the data continue to pull from this new workbook or will I need to fix all the other workbooks.
This comment was minimized by the moderator on the site
Hi Michelle,
After saving the workbook as an Macro-Enabled Excel workbook, the code still works fine.
This comment was minimized by the moderator on the site
Awesome! Thanks for this tutorial.


However, how do i insert ONLY the date in DD/MM/YYYY format?
This comment was minimized by the moderator on the site
Hi,
You can format the output cell as Short Date formatting to solve the problem.
This comment was minimized by the moderator on the site
Hi there.. this is really good basic info..


One question - how do you modify the code to put the datestamp into the NEXT row below, each time the button is pressed? (keeping the data previously written above?)


Thank you so much!
This comment was minimized by the moderator on the site
Hi,
The below VBA code will work on selected cell. When you want to insert timestampe to a cell, just select it and press the button.

Private Sub CommandButton1_Click()
Dim xRg As Range
On Error Resume Next
Set xRg = Selection
xRg.Value = Now()
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