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

كيفية حساب مجموع النقرات في خلية محددة في إكسيل؟

تتحدث هذه المقالة عن حساب إجمالي النقرات في خلية محددة في Excel.

حساب إجمالي النقرات في خلية محددة برمز VBA


حساب إجمالي النقرات في خلية محددة برمز VBA

يرجى القيام بما يلي لحساب إجمالي النقرات في خلية محددة في Excel.

1. في ورقة العمل تحتوي على الخلية التي تحتاجها لحساب إجمالي النقرات ، انقر بزر الماوس الأيمن فوق علامة تبويب الورقة ، ثم انقر فوق عرض الرمز من قائمة السياق.

2. في ال ميكروسوفت فيسوال باسيك للتطبيقات نافذة ، يرجى نسخ ولصق رمز VBA أدناه في نافذة التعليمات البرمجية.

رمز فبا: حساب إجمالي النقرات في خلية محددة في إكسيل

Public xRgS, xRgD As Range
Public xNum As Long
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error Resume Next
    If Target.Cells.Count > 1 Then Exit Sub
    Set xRgS = Range("E2")
    If xRgS Is Nothing Then Exit Sub
    Set xRgD = Range("H2")
    If xRgD Is Nothing Then Exit Sub
    If Intersect(xRgS, Target) Is Nothing Then Exit Sub
    xNum = xNum + 1
    xRgD.Value = xNum
End Sub

ملاحظات: في الكود ، E2 هي الخلية التي تحتاجها لحساب إجمالي نقراتها ، و H2 هي خلية إخراج العد. الرجاء تغييرها كما تريد.

3. اضغط على قديم + Q مفاتيح لإغلاق ميكروسوفت فيسوال باسيك للتطبيقات نافذة.

من الآن فصاعدًا ، عند النقر فوق الخلية E2 في ورقة العمل المحددة هذه ، سيتم ملء إجمالي النقرات تلقائيًا في الخلية H2 كما هو موضح أدناه. على سبيل المثال ، إذا قمت بالنقر فوق الخلية E2 5 مرات ، فسيتم عرض الرقم 5 في الخلية H2.

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

🤖 مساعد 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 (31)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi.
thanks for your amazing code.
as i use this, the counter get restarted every time i open the file,
is there any solution for this issue?
i need to see thclick counts in a larger time window

thanks in advance
This comment was minimized by the moderator on the site
Hi Mehrdad,
I am sorry to reply to you so late. The following code can help solve your problem. Every time you open the file, the counter will start counting from the last counted number.

Public xRgS, xRgD As Range
'Updated by Extendoffice 20230407
Public xNum As Long
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error Resume Next
    If Target.Cells.Count > 1 Then Exit Sub
    Set xRgS = Range("E2")
    If xRgS Is Nothing Then Exit Sub
    Set xRgD = Range("H2")
    If xRgD Is Nothing Then Exit Sub
    If Intersect(xRgS, Target) Is Nothing Then Exit Sub
    xNum = xRgD.Value
    xNum = xNum + 1
    xRgD.Value = xNum
End Sub
This comment was minimized by the moderator on the site
Hola. Muchas gracias por los códigos.
Me gustaría saber cómo contar las veces que se hace clic sobre un enlace en una celda.
Muchas gracias.
This comment was minimized by the moderator on the site
Hi jose maria,
To count the clicks on a hyperlink, you can try the following VBA code.
Suppose hyperlinks are in column A and you want the number of clicks to be populated in the corresponding cell of column B (as shown in the screenshot below)
Please put the following code in the worksheet (code) window.

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
'Updated by Extendoffice 20220805
    Dim Hyperlink As Range
    Set Hyperlink = Target.Range

    Hyperlink.Offset(0, 1) = Hyperlink.Offset(0, 1) + 1
End Sub

https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/clicks_on_a_hyperlink.png
This comment was minimized by the moderator on the site
Bonjour ,
j'aimerai comment je pourrais le nombre de clics sur les cellules D10 à M10 et le retranscrire à la ligne R10 et le faire pour toutes les lignes suivante donc compter les clics sur les cellules D11 à M11 et le transcrire à la ligne R11 etc etc ?

Cordialement
This comment was minimized by the moderator on the site
Hi DUFOUR,
To count the number of clicks from D10 to M10 and output the total number of clicks in R10, you can apply the following VBA code to get it done.
Note: In the code, the range "D10:M30" means that the code only works from the row 10 to row 30, so please specify the rows you want to count.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updated by Extendoffice 20220609
    Dim xNum As Long
    Dim xRgCount, xRg As Range
    
    On Error Resume Next
    If Target.Cells.Count > 1 Then Exit Sub

    Set xRg = Range("D10:M30")
    If Intersect(xRg, Target) Is Nothing Then Exit Sub
    Set xRgCount = Range("R" & Target.Row)
    
    If IsNumeric(xRgCount.Value) Then
        xNum = xRgCount.Value + 1
    Else
        xNum = 1
    End If
    xRgCount.Value = xNum
End Sub
This comment was minimized by the moderator on the site
Is there a way to backtrack the number count? For exemple: I'd made 5 clicks, but I just wanted 3. So I change the number in the cell to 3, and when I click again, it continues from 3. OR have the ability to press another cell and decrease the count by 1 if that is easier.
This comment was minimized by the moderator on the site
Hi, thank you for these VBA codes, they almost work for my needs. I fear the fact I need to go past double digits means it will not work. I need to have C8 through to C110 and the corresponding tally count being L8 through to L110. Can you help? Many thanks in advance.
This comment was minimized by the moderator on the site
Hi Andy,The following VBA code can do you a favor. Please have a try.<div data-tag="code">Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xRgS, xRgD As Range
Dim xStrRg As String
Dim xCStr, xVStr As String
Dim xItem As Integer
xCStr = "C8:C110" 'The range of cells you want to record the clicks of each cell
xVStr = "L8:L110" 'The range of cells to place the records in
Set xRgS = Range(xCStr)
Set xRgD = Range(xVStr)
If Not (Intersect(xRgS, Target) Is Nothing) Then
xItem = Target.Row - xRgS.Item(1).Row + 1
xRgD.Item(xItem).Value = xRgD.Item(xItem).Value + 1
End If
End Sub
This comment was minimized by the moderator on the site
Hi, I'm trying to find a way of counting the number of times 20 different cells are being clicked (each one should be counted separately). I came across your VBA code suggestion, tried to adjust it to my specific needs but it won't work. can you please advise how the code should be written? the cells that I would like to count and the cells that the values should appear in are: F12>AU12, F13>AU13, G12>AV12, G13>AV13, H10>AW10, H11>AW11, H12>AW12, H13>AW13, H14>AW14, H15>AW15, I10>AX10, I11>AX11, I12>AX12, I13>AX13, I14>AX14, I15>AX15, J12>AY12, J13>AY13, K12>AZ12, K13>AZ13).
This is the VBA code I've tried with no success:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xRgArray As Variant
Dim xNum
Dim xStrR, xStrS, xStrD As String
Dim xRgS, xRgD As Range

Dim xFNum As Long
xRgArray = Array("F12,AU12", "F13,AU13", "G12,AV12", "G13,AV13", "H10,AW10", "H11,AW11", "H12,AW12", "H13,AW13", "H14,AW14", "H15,AW15", "I10,AX10", "I11,AX11", "I12,AX12", "I13,AX13", "I14,AX14", "I15,AX15", "J12,AY12", "J13,AY13", "K12,AZ12", "K13,AZ13")
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
For xFNum = LBound(xRgArray) To UBound(xRgArray)
xStrR = xRgArray(xFNum)
xStrS = ""
xStrS = Left(xStrR, 2)
xStrD = ""
xStrD = Right(xStrR, 2)
Set xRgS = Nothing
Set xRgS = Range(xStrS)
If TypeName(xRgS) <> "Nothing" Then
Set xRgD = Nothing
Set xRgD = Range(xStrD)
If TypeName(xRgD) <> "Nothing" Then
If TypeName(Intersect(xRgS, Target)) <> "Nothing" Then
xRgD.Value = xRgD.Value + 1
End If
End If
End If
Next
End Sub

Thank you in advance, for your help.
This comment was minimized by the moderator on the site
Hi,The below code can help. Please have a try. Thank you.<div data-tag="code">Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xRgS, xRgD As Range
Dim xStrRg As String
Dim xFNum As Integer
Dim xArr1, xArr2
If Target.Cells.Count > 1 Then Exit Sub
xStrRg = "F12-AU12; F13-AU13; G12-AV12; G13-AV13; H10-AW10; H11-AW11; H12-AW12; H13-AW13; H14-AW14; H15-AW15; I10-AX10; I11-AX11; I12-AX12; I13-AX13; I14-AX14; I15-AX15; J12-AY12; J13-AY13; K12-AZ12; K13-AZ13"
On Error Resume Next
xArr1 = Split(xStrRg, ";")
For xFNum = 0 To UBound(xArr1)
xArr2 = Split(xArr1(xFNum), "-")
Set xRgS = Range(xArr2(0))
Set xRgD = Range(xArr2(1))
If Not (Intersect(xRgS, Target) Is Nothing) Then
xRgD.Value = xRgD.Value + 1
End If
Next
End Sub
This comment was minimized by the moderator on the site
Crystal, The Above code is great for the sheet I am working with, thank you. But I have a question about adding a time macro so that everyday (excluding weekends) the tally moves to the next row in the sheet for example:

Row 3 - 7/1/2021 "B1-B3; C1-C3; D1-D3"
Row 4 - 7/2/2021 "B1-B4; C1-C4; D1-D4"
Row 5 - 7/3/2021 "B1-B5; C1-C5; D1-D5"

If this is possible? thx, Ken
This comment was minimized by the moderator on the site
The Above corrected code is great for the sheet I am working with, thank you. But I have a question about adding a time macro so that everyday (excluding weekends) the tally moves to the next row in the sheet for example:
Row 3 - 7/1/2021 "B1-B3; C1-C3; D1-D3"Row 4 - 7/2/2021 "B1-B4; C1-C4; D1-D4"Row 5 - 7/3/2021 "B1-B5; C1-C5; D1-D5"
This comment was minimized by the moderator on the site
Como zerar a contagem? How to reset the score?
This comment was minimized by the moderator on the site
Hi,
If you want to reset the counter, please add the below VBA code at the end of the original code which has been provided above, and then run it.

Sub ClearCount()
xRgD.Value = ""
xNum = 0
End Sub
This comment was minimized by the moderator on the site
Can you provide a code that allows counting clicks from A2, B2 cells through A14, B14 cells. Thanks in advance.
This comment was minimized by the moderator on the site
Hi Barbara,
Do you mean counting the total clicks in range A2:B14? Or clicks for each cell in range A2:B14?
This comment was minimized by the moderator on the site
Hola
Hay alguna manera de programar el conteo de clicks de acuerdo a la fecha, es decir programar varias celdas para que cuenten con la fecha del día?
This comment was minimized by the moderator on the site
Hello, there is a way to back the counting for any number that I want? For exemple: I'd made 5 clicks, but i just wanted 3. So I change the number in the cell to 3, and when I click again, it continue from 3.
Thank for the code!
This comment was minimized by the moderator on the site
Hi,
Sorry can’t help you with this, welcome to post any question about Excel to our forum: https://www.extendoffice.com/forum.html. You will get more Excel supports from our professional or other Excel fans.
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