انتقل إلى المحتوى الرئيسي

كيفية إنشاء ساعة توقيت في ورقة عمل Excel؟

إذا كانت هناك ساعة توقيت في ورقة العمل الخاصة بك ، فستعرف الوقت اللازم لإنهاء المهمة. كيف يمكنك إنشاء ساعة توقيت في ورقة باستخدام زر البدء والإيقاف وإعادة الضبط كما هو موضح في لقطة الشاشة التالية؟ إذا قمت بالنقر فوق الزر "ابدأ" ، فسيبدأ الوقت ، وإذا قمت بالنقر فوق الزر "إيقاف" ، فسيتوقف الوقت ، ويمكن أن يساعدك الزر "إعادة تعيين" في إعادة تعيين الوقت. في هذه المقالة ، سأتحدث عن كيفية إنشاء ساعة توقيت بسيطة وسهلة الاستخدام في Excel.

doc إنشاء ساعة توقيت 1

قم بإنشاء ساعة توقيت بثلاثة أزرار باستخدام كود فبا


قم بإنشاء ساعة توقيت بثلاثة أزرار باستخدام كود فبا

لإنشاء ساعة توقيت بثلاثة أزرار ، ابدأ وإيقاف وإعادة تعيين ، يرجى اتباع الخطوات التالية واحدة تلو الأخرى.

أولاً ، أدخل ثلاثة أزرار أوامر.

1. انقر المطور > إدراج > زر الأوامر، انظر لقطة الشاشة:

doc إنشاء ساعة توقيت 2

2. ثم اسحب الماوس لرسم زر ، بعد إدخال الزر ، يمكنك تغيير تسمية الزر ، من فضلك انقر المطور > عقارات، في عقارات الحوار ، أدخل التسمية التوضيحية الجديدة "آبدأ"لهذا الزر في مربع النص بجانب شرح، انظر لقطات الشاشة:

doc إنشاء ساعة توقيت 3 2 doc إنشاء ساعة توقيت 4

3. كرر الخطوتين السابقتين لإدراج زرين آخرين وتعليقهما كـ "قلة النوم"و"إعادة تعيين"، انظر لقطة الشاشة:

doc إنشاء ساعة توقيت 5

4. بعد إدخال الأزرار ، يجب الخروج من وضع التصميم بالنقر فوق المطور > وضع التصميم.

ثانيًا ، قم بإنشاء كود VBA.

5. وبعد ذلك ، انقر بزر الماوس الأيمن فوق علامة تبويب ورقة العمل الحالية ، واختر عرض الرمز، في المنبثقة ميكروسوفت فيسوال باسيك للتطبيقات نافذة ، يرجى نسخ ولصق الكود التالي في ملف كود الورقة:

كود فبا: إنشاء ساعة توقيت:

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

doc إنشاء ساعة توقيت 6

ملاحظات: في الكود أعلاه ، C2 هي الخلية التي سيتم إدراج وقت ساعة الإيقاف فيها ، و زر الأوامر1, زر الأوامر2, زر الأوامر3 هي أسماء الأزرار ، يمكنك عرض اسم الزر الدقيق من ملف اسم صندوق، انظر لقطة الشاشة:

doc إنشاء ساعة توقيت 7

ثالثًا ، قم بتنسيق الخلية الزمنية لساعة الإيقاف.

6. ثم يجب عليك تنسيق الخلية الزمنية كـ نص التنسيق ، ويمكنك تغيير حجم الخلية والخط ولون الخط والخلفية وما إلى ذلك حسب حاجتك ، انظر لقطة الشاشة:

doc إنشاء ساعة توقيت 8

7. بعد الانتهاء من الخطوات المذكورة أعلاه ، من الآن فصاعدًا ، عند النقر فوق آبدأ زر ، الوقت سيبدأ الآن ، وانقر قلة النوم زر ، وسوف يوقف الوقت ، و إعادة تعيين زر إعادة تعيين الوقت ، انظر لقطة الشاشة:

doc إنشاء ساعة توقيت 9


عرض توضيحي: قم بإنشاء ساعة توقيت بثلاثة أزرار باستخدام كود فبا

أفضل أدوات إنتاجية المكتب

🤖 مساعد Kutools AI: إحداث ثورة في تحليل البيانات على أساس: التنفيذ الذكي   |  إنشاء التعليمات البرمجية  |  إنشاء صيغ مخصصة  |  تحليل البيانات وإنشاء الرسوم البيانية  |  استدعاء وظائف Kutools...
الميزات الشعبية: البحث عن التكرارات أو تمييزها أو تحديدها   |  حذف الصفوف الفارغة   |  دمج الأعمدة أو الخلايا دون فقدان البيانات   |   جولة بدون صيغة 
سوبر بحث: معايير متعددة VLookup    VLookup ذات القيمة المتعددة  |   VLookup عبر أوراق متعددة   |   بحث غامض ....
قائمة منسدلة متقدمة: إنشاء القائمة المنسدلة بسرعة   |  القائمة المنسدلة التابعة   |  قائمة منسدلة متعددة التحديد ....
مدير العمود: إضافة عدد محدد من الأعمدة  |  نقل الأعمدة  |  تبديل حالة رؤية الأعمدة المخفية  |  مقارنة النطاقات والأعمدة 
الميزات المميزة: التركيز على الشبكة   |  عرض تصميم   |   شريط الفورمولا الكبير    مدير المصنفات والأوراق   |  مكتبة الموارد (النص السيارات)   |  منتقي التاريخ   |  اجمع أوراق العمل   |  تشفير/فك تشفير الخلايا    إرسال رسائل البريد الإلكتروني عن طريق القائمة   |  سوبر تصفية   |   مرشح خاص (تصفية غامق / مائل / يتوسطه خط ...) ...
أفضل 15 مجموعة أدوات12 نص الأدوات (إضافة نص, إزالة الأحرف، ...)   |   +50 رسم الأنواع (مخطط جانت، ...)   |   40+ عملي الصيغ (احسب العمر على أساس تاريخ الميلاد، ...)   |   19 إدخال الأدوات (أدخل رمز الاستجابة السريعة, إدراج صورة من المسار، ...)   |   12 تحويل الأدوات (أرقام إلى كلمات, نتيجة تحويل عملة، ...)   |   7 دمج وتقسيم الأدوات (الجمع بين الصفوف المتقدمة, تقسيم الخلايا، ...)   |   ... و اكثر

عزز مهاراتك في Excel باستخدام Kutools for Excel، واختبر كفاءة لم يسبق لها مثيل. يقدم Kutools for Excel أكثر من 300 ميزة متقدمة لتعزيز الإنتاجية وتوفير الوقت.  انقر هنا للحصول على الميزة التي تحتاجها أكثر...

الوصف


يجلب Office Tab الواجهة المبوبة إلى Office ، ويجعل عملك أسهل بكثير

  • تمكين التحرير والقراءة المبوبة في Word و Excel و PowerPointوالناشر والوصول و Visio والمشروع.
  • فتح وإنشاء مستندات متعددة في علامات تبويب جديدة من نفس النافذة ، بدلاً من النوافذ الجديدة.
  • يزيد من إنتاجيتك بنسبة 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