Number of values ​​that are not repeated in the column in Excel

xiaoxiao2021-03-06  37

Public Sub DistinctCount ()

'Request for the number of non-repetitions in the COL column

'This example is the number of non-repetition values ​​of the A1: A240 in the Excel table of the title of Sheet1

'Modify the end value of the following four lines

DIM Sheetscaption As String: Sheetscaption = "Sheet1"

DIM COL AS STRING: COL = "a"

DIM Startrow as integer: Startrow = 1

DIM endrow as integer: endrow = 240

'Below fixed

DIM Count As integer: count = 0

WITH Sheets (Sheetscaption)

For i = startrow to endrow

Count = count 1

For J = Startrow To I - 1

IF.RANGE (COL & I) = .range (col & j) THEN

Count = count - 1

EXIT for

END IF

NEXT

NEXT

End with

Msgbox Count

End Sub

转载请注明原文地址:https://www.9cbs.com/read-62182.html

New Post(0)