I need help with this problem. I have a column on sheet 1 that with has the following:
Sites
A
A
B
D
A
C
B
D
I need to count for each site and display it on sheet 2 using vba as shown.
Sites
A 3
B 2
C 1
D 2
I have the following code, but I know its going to need an array but I having trouble think on how it is done. Thanks for the help.
BTW the information will always start on row 5.
Sites
A
A
B
D
A
C
B
D
I need to count for each site and display it on sheet 2 using vba as shown.
Sites
A 3
B 2
C 1
D 2
I have the following code, but I know its going to need an array but I having trouble think on how it is done. Thanks for the help.
BTW the information will always start on row 5.
Code:
Sub test()
Dim i As Integer
Dim x As Integer
Dim c As Integer
Dim stName As String
c = 0
stName = Sheet1.Cells(5, 4).Value
i = Sheet1.Cells.SpecialCells(xlCellTypeLastCell).Row
For x = 5 To i
If stName = Sheet1.Cells(x, 4).Value Then
c = c + 1
End If
Next x
End Sub