Niraj Baraili
Member
Hi Experts,
I have a large data set where i have to use countif function to take count how many times the number is repeated. I have attached a demo file for better understanding. I have two columns A and B, where in Col A i have repeated numbers and in column B i need to take to find out how many times the number is repeating.I tried using countif function but it's taking lot of time. Then i found the below code in internet, but not sure how to make changes as per my requirement.(Pivot table approach is not preferable)
Any help on this is greatly appreciated.
I have a large data set where i have to use countif function to take count how many times the number is repeated. I have attached a demo file for better understanding. I have two columns A and B, where in Col A i have repeated numbers and in column B i need to take to find out how many times the number is repeating.I tried using countif function but it's taking lot of time. Then i found the below code in internet, but not sure how to make changes as per my requirement.(Pivot table approach is not preferable)
Code:
Sub sbADOExample()
Dim sSQLQry As String
Dim ReturnArray
Dim Conn As New ADODB.Connection
Dim mrs As New ADODB.Recordset
Dim DBPath As String, sconnect As String
DBPath = ThisWorkbook.FullName
'You can provide the full path of your external file as shown below
'DBPath ="C:\InputData.xlsx"
sconnect = "Provider=MSDASQL.1;DSN=Excel Files;DBQ=" & DBPath & ";HDR=Yes';"
Conn.Open sconnect
sSQLSting = "SELECT * From [Test$]" ' Your SQL Statement (Table Name= Sheet Name=[Sheet1$])
mrs.Open sSQLSting, Conn
'=>Load the Data into an array
'ReturnArray = mrs.GetRows
''OR''
'=>Paste the data into a sheet
Sheet2.Range("A2").CopyFromRecordset mrs
'Close Recordset
mrs.Close
'Close Connection
Conn.Close
End Sub
Any help on this is greatly appreciated.