Sub AutoStat()
'
Dim Row As Integer
Dim SheetCount As Integer
Dim MegerRow As Integer
Dim UsedRow As Integer
Dim Hcount As Integer
Dim Mcount As Integer
Dim Lcount As Integer
'Row = 2
SheetCount = 1
UsedRow = Sheets(SheetCount).UsedRange.Rows.Count
For Row = 2 To UsedRow
'先判断是否是merge cell
If Cells(Row, 5).MergeCells = True Then
'清空
Hcount = 0
Mcount = 0
Lcount = 0
MegerRow = Row
Else
Select Case Cells(Row, 5).Text
Case "H"
Hcount = Hcount + 1
Case "h"
Hcount = Hcount + 1
Case "m"
Mcount = Mcount + 1
Case "M"
Mcount = Mcount + 1
Case "L"
Lcount = Lcount + 1
Case "l"
Lcount = Lcount + 1
End Select
Cells(MegerRow, 1).Select
ActiveCell.FormulaR1C1 = Hcount & " " & Mcount & " " & Lcount
End If
Next
End Sub
'
Dim Row As Integer
Dim SheetCount As Integer
Dim MegerRow As Integer
Dim UsedRow As Integer
Dim Hcount As Integer
Dim Mcount As Integer
Dim Lcount As Integer
'Row = 2
SheetCount = 1
UsedRow = Sheets(SheetCount).UsedRange.Rows.Count
For Row = 2 To UsedRow
'先判断是否是merge cell
If Cells(Row, 5).MergeCells = True Then
'清空
Hcount = 0
Mcount = 0
Lcount = 0
MegerRow = Row
Else
Select Case Cells(Row, 5).Text
Case "H"
Hcount = Hcount + 1
Case "h"
Hcount = Hcount + 1
Case "m"
Mcount = Mcount + 1
Case "M"
Mcount = Mcount + 1
Case "L"
Lcount = Lcount + 1
Case "l"
Lcount = Lcount + 1
End Select
Cells(MegerRow, 1).Select
ActiveCell.FormulaR1C1 = Hcount & " " & Mcount & " " & Lcount
End If
Next
End Sub