VBA to count numbers between columns

aaaaa34

Board Regular
Joined
Feb 25, 2014
Messages
62
Hello guys,
I'd like to ask your help for VBA to count numbers between columns Q:Z columns in which rows have values more than three.
In the attached file, you will see there are three and more numbers in Rows no.3-4-9-11-12-13-15-17-18-21
I want to know these numbers how many times are written in these rows.
Please have a look into the attached file, you will see (desired) result in the worksheet.

File: Book1.xlsx (Click to "Download" in right-up corner of opened page)

Thank you so much for your interest.
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
How about
VBA Code:
Sub aaaa34()
   Dim Ary As Variant
   Dim r As Long, c As Long
   
   Ary = Range("Q2:Z" & Range("Q" & Rows.Count).End(xlUp)).Value2
   With CreateObject("scripting.dictionary")
      For r = 1 To UBound(Ary)
         If Ary(r, 3) <> "" Then
            For c = 1 To UBound(Ary, 2)
               If Ary(r, c) = "" Then Exit For
               .Item(Ary(r, c)) = .Item(Ary(r, c)) + 1
            Next c
         End If
      Next r
      Range("AB2").Resize(.Count, 2).Value = Application.Transpose(Array(.Keys, .Items))
   End With
End Sub
 
Upvote 0
Thank you, Fluff
You always here to help generously
I wish I could be successful and consistent like you in this life at least in one branch.
Thank you so much Fluff, you're great.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Has this got anything to do with this thread?
 
Upvote 0
In that case what error do you get & what line is highlighted?
 
Upvote 0
This error I got.
Sth about my office version 2013?
 

Attachments

  • R1.png
    R1.png
    24.9 KB · Views: 6
  • R2.png
    R2.png
    13.3 KB · Views: 5
Upvote 0
That suggests that the dictionary is empty, but not sure why.
Will there ever be a situation where you never have 3 or more numbers in a row?
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,293
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top