메인 컨텐츠로 가기

Excel 워크 시트에서 스톱워치를 만드는 방법은 무엇입니까?

워크 시트에 스톱워치가 있으면 작업 완료 시간을 알 수 있습니다. 다음 스크린 샷과 같이 시작, 중지 및 재설정 단추가있는 시트에 스톱워치를 어떻게 만들 수 있습니까? 시작 버튼을 클릭하면 시간이 시작되고, 중지 버튼을 클릭하면 시간이 중지되며, 재설정 버튼을 사용하면 시간을 재설정 할 수 있습니다. 이 기사에서는 Excel에서 간단하고 편리한 스톱워치를 만드는 방법에 대해 설명합니다.

문서는 스톱워치를 만들 1

VBA 코드를 사용하여 세 개의 버튼이있는 스톱워치 만들기


VBA 코드를 사용하여 세 개의 버튼이있는 스톱워치 만들기

시작, 중지 및 재설정의 세 개의 버튼이있는 스톱워치를 만들려면 다음 단계를 하나씩 수행하십시오.

먼저 세 개의 명령 단추를 삽입하십시오.

1. 딸깍 하는 소리 개발자 > 끼워 넣다 > 명령 단추, 스크린 샷 참조 :

문서는 스톱워치를 만들 2

2. 그런 다음 마우스를 드래그하여 버튼을 그립니다. 버튼을 삽입 한 후 버튼 캡션을 변경할 수 있습니다. 개발자 > 등록,에 등록 대화 상자에 새 캡션을 입력하십시오.“스타트”옆의 텍스트 상자에있는이 버튼 표제, 스크린 샷 참조 :

문서는 스톱워치를 만들 3 2 문서는 스톱워치를 만들 4

3. 위의 두 단계를 반복하여 다른 두 개의 버튼을 삽입하고 "중지"및"다시 쓰기”, 스크린 샷 참조 :

문서는 스톱워치를 만들 5

4. 버튼을 삽입 한 후 버튼을 클릭하여 디자인 모드를 종료해야합니다. 개발자 > 디자인 모드.

둘째, VBA 코드를 만듭니다.

5. 그런 다음 현재 워크 시트 탭을 마우스 오른쪽 단추로 클릭하고 코드보기, 튀어 나온 응용 프로그램 용 Microsoft Visual Basic 창에 다음 코드를 복사하여 붙여 넣으십시오. 시트 코드:

VBA 코드 : 스톱워치 만들기 :

Public StopIt As Boolean
Public ResetIt As Boolean
Public LastTime
Private Sub CommandButton1_Click()
Dim StartTime, FinishTime, TotalTime, PauseTime
StopIt = False
ResetIt = False
If Range("C2") = 0 Then
  StartTime = Timer
  PauseTime = 0
  LastTime = 0
Else
  StartTime = 0
  PauseTime = Timer
End If
StartIt:
  DoEvents
  If StopIt = True Then
    LastTime = TotalTime
    Exit Sub
  Else
    FinishTime = Timer
    TotalTime = FinishTime - StartTime + LastTime - PauseTime
    TTime = TotalTime * 100
    HM = TTime Mod 100
    TTime = TTime \ 100
    hh = TTime \ 3600
    TTime = TTime Mod 3600
    MM = TTime \ 60
    SS = TTime Mod 60
    Range("C2").Value = Format(hh, "00") & ":" & Format(MM, "00") & ":" & Format(SS, "00") & "." & Format(HM, "00")
    If ResetIt = True Then
      Range("C2") = Format(0, "00") & ":" & Format(0, "00") & ":" & Format(0, "00") & "." & Format(0, "00")
      LastTime = 0
      PauseTime = 0
      End
    End If
    GoTo StartIt
  End If
End Sub
Private Sub CommandButton2_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  StopIt = True
End Sub
Private Sub CommandButton3_Click()
  Range("C2").Value = Format(0, "00") & ":" & Format(0, "00") & ":" & Format(0, "00") & "." & Format(0, "00")
  LastTime = 0
  ResetIt = True
End Sub

문서는 스톱워치를 만들 6

주의 사항: 위 코드에서 C2 스톱워치 시간이 삽입 될 셀이며 커맨드 버튼1, 커맨드 버튼2, 커맨드 버튼3 버튼 이름입니다. 정확한 버튼 이름은 이름 상자, 스크린 샷 참조 :

문서는 스톱워치를 만들 7

셋째, 스톱워치 시간 셀의 형식을 지정합니다.

6. 그런 다음 시간 셀을 다음과 같이 형식화해야합니다. 본문 형식, 필요에 따라 셀 크기, 글꼴, 글꼴 색상, 배경 등을 변경할 수 있습니다. 스크린 샷을 참조하십시오.

문서는 스톱워치를 만들 8

7. 위의 단계를 마친 후 지금부터 스타트 버튼을 누르면 시간이 시작됩니다. 중지 버튼을 누르면 시간이 중지됩니다. 다시 쓰기 버튼은 시간을 재설정합니다. 스크린 샷 참조 :

문서는 스톱워치를 만들 9


데모 : VBA 코드를 사용하여 세 개의 버튼이있는 스톱워치 만들기

최고의 사무 생산성 도구

🤖 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 (32)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
One has to paste the VBA code to the Sheet's VBA space, not to the Module!

=> I suggest correcting, in the article, the "copy and paste the following code into the Module" -> replace Module with Sheet's VBA field, or sth

Otherwise, perfect, thanks!
This comment was minimized by the moderator on the site
Hello, Florian,

Thanks for your comment, we have updated the content for this article.
Thanks again! 😀
This comment was minimized by the moderator on the site
i started. it works. but it doesn't work when i close and open the excel file again. what must i do?
This comment was minimized by the moderator on the site
Hello, mustafa zirek
After inputing the code, you should save the workbook as Excel Macro-Enabled Workbook format, and when you open the workbook next time, please click the Enable Content above the formula bar to activate the code.
Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Hi! Thank you for this, how do I make it so it populates time in subsequent cells, ex. start/stop time for cell C2, then a different start/stop time for cell c3, c4, c5 etc 
This comment was minimized by the moderator on the site
Bonjour, j'ai voulu intégrer ce chronomètre à une autre macro, déterminer le temps d'utilisation du fichier. La macro se lance mais bloque l'utilisation du fichier.Comment faire pour utiliser votre chronomètre en même temps que d'autres codes VBA?MerciHenry.
This comment was minimized by the moderator on the site
Is it possible to use a combobox or a dropdown selection to start and stop the clock
This comment was minimized by the moderator on the site
This is brilliant! Thanks, Chris H
This comment was minimized by the moderator on the site
Hello
Have followed the steps but cannot get a time to appear in the timer cell. I have copied the code but can i check1. That the line numbers are not needed or are they2. That I put the code into module 1 not sheet1 or This workbook3. Should there be a macro listed in the macro list after doing all this - mine doesn't.
Thanks
This comment was minimized by the moderator on the site
Hi, Janice,You should put the code into your active sheet module as step 5.
5. And then, right click the current worksheet tab, and choose View Code, in the popped out Microsoft Visual Basic for Applications window, please copy and paste the following code into the Module.

And you should change the button name to your own.
Note: In the above code, C2 is the cell where the stopwatch time will be inserted, and the CommandButton1, CommandButton2, CommandButton3 are the button names, you can view the exact button name from the Name Box.

Please check them, thank you!
This comment was minimized by the moderator on the site
Is it possible to get the counter to count only seconds?
So when it reaches 59 seconds, it continues with 60, 61, 62, 63 ....
This comment was minimized by the moderator on the site
is 'timer' a variable here? dont see its relevance in the code.
This comment was minimized by the moderator on the site
How about adding "+10s" & "2x Speed" feature in this code?
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