본문 바로가기

VB.NET

[질답] 셀의 개수 통계내는 vba 도와주세요

반응형

사진처럼 해당날짜의 조건에 맞는통계를 구하는 매크로를 넣고싶은데요

버튼을 누르면 통계부분에
< 일자, 주/야,이름 >이렇게 세조건이 맞는 셀의 개수가 들어갔으면 합니다

김-1
박-1 
이것도 김, 박에 같이 포함됩니다

도와주세요~!

첨부 이미지





일본어판 윈도우라서... 한글로 인식을 못하므로 보기를 조금 바꿔서 했습니다.

첨부 이미지




소스는 아래와 같습니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Sub ボタン1_Click()
 
For i = 2 To 10000 Step 1
 
    key1 = ActiveSheet.Cells(i, 1).Value
    Key2 = ActiveSheet.Cells(i, 2).Value
    key3 = ActiveSheet.Cells(i, 3).Value
    
    If key1 = "" Then
        Exit For
    Else
        If key1 = "2018/01/18" Then
            If Key2 = "A" Then
                If InStr(key3, "kim"> 0 Then
                    ActiveSheet.Cells(28).Value = ActiveSheet.Cells(28).Value + 1
                Else
                    ActiveSheet.Cells(38).Value = ActiveSheet.Cells(38).Value + 1
                End If
            Else
                If InStr(key3, "kim"> 0 Then
                    ActiveSheet.Cells(48).Value = ActiveSheet.Cells(48).Value + 1
                Else
                    ActiveSheet.Cells(58).Value = ActiveSheet.Cells(58).Value + 1
                End If
            End If
        End If
    End If
Next i
 
End Sub
 
cs



반응형