2의 갯수만 세고 싶은데 최종 갯수옆의 (날짜)(숫자)는 그대로 가져가고 싶습니다.
커뮤니티 전체
숫자 갯수 세기
📅 2026년 01월 15일 22:36
👁 조회 480
댓글을 작성하려면 로그인이 필요합니다.
게시글 목록
페이지 1 / 971게시글 제목
날짜
조회
추천
3일 전
조회 137
0
답글 2
답변 완료
주민번호에서 남,여 추출 수식..
3일 전
조회 160
0
답글 4
해결
3일 전
조회 157
0
답글 2
해결
4일 전
조회 177
0
답글 1
4일 전
조회 190
0
답글 3
답변 완료
물품별로 코드를 만들어야합니다
4일 전
조회 196
0
답글 2
해결
5일 전
조회 163
0
답글 2
5일 전
조회 209
0
답글 2
해결
5일 전
조회 174
0
답글 1
답변 완료
시트명 참조 문의 드립니다.
6일 전
조회 213
0
답글 3
해결
답변 완료
엑셀 함수 SUBTOTAL 질문드립니다.
6일 전
조회 195
0
답글 1
해결
2026.02.08
조회 304
0
답글 4
2026.02.06
조회 372
0
답글 8
2026.02.06
조회 304
0
답글 2
2026.02.05
조회 465
0
답글 4
2026.02.05
조회 340
0
답글 7
2026.02.04
조회 380
0
답글 3
해결
2026.02.04
조회 289
0
답글 1
2026.02.04
조회 357
0
답글 1
2026.02.04
조회 351
0
답글 6
해결

안녕하세요~

아래 첨부파일로 적용해보세요.
Public Sub 그룹별숫자카운트() On Error GoTo EH Dim ws As Worksheet Set ws = ActiveSheet Application.ScreenUpdating = False Dim tgt As Long Dim sIn As String sIn = InputBox("첫번째 괄호 '(' 앞의 숫자를 입력하세요.", "그룹별 카운트") If Len(Trim$(sIn)) = 0 Then Exit Sub If Not IsNumeric(sIn) Then Exit Sub tgt = CLng(sIn) Dim sCol As Long, eCol As Long sCol = ws.Range("I1").Column eCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column If eCol < sCol Then Exit Sub Dim d As Object Set d = CreateObject("Scripting.Dictionary") Dim c As Long, lr As Long Dim grp As String Dim arr As Variant Dim i As Long Dim s As String Dim n As Long Dim cnt As Long Dim last As String For c = sCol To eCol grp = Trim$(CStr(ws.Cells(1, c).Value)) If Len(grp) = 0 Then GoTo NextCol lr = ws.Cells(ws.Rows.Count, c).End(xlUp).Row If lr < 2 Then d(grp) = Array(tgt, 0&, vbNullString) GoTo NextCol End If arr = ws.Range(ws.Cells(2, c), ws.Cells(lr, c)).Value2 cnt = 0 last = vbNullString If IsArray(arr) Then For i = 1 To UBound(arr, 1) If Len(CStr(arr(i, 1))) > 0 Then s = CStr(arr(i, 1)) n = LeadNum(s) If n = tgt Then cnt = cnt + 1 last = s End If End If Next i Else '//' 단일 셀 범위인 경우(방어) s = CStr(arr) n = LeadNum(s) If n = tgt Then cnt = 1 last = s End If End If d(grp) = Array(tgt, cnt, last) NextCol: Next c '//' 출력 Dim k As Variant Dim out() As Variant Dim r As Long, m As Long m = d.Count If m = 0 Then Exit Sub ReDim out(1 To m, 1 To 4) r = 0 For Each k In d.Keys r = r + 1 out(r, 1) = CStr(k) '//' A: 그룹명 out(r, 2) = d(k)(0) '//' B: 입력 숫자 out(r, 3) = d(k)(1) '//' C: 갯수 out(r, 4) = d(k)(2) '//' D: 마지막 매칭 셀값 Next k With ws.Range("A1:D1") .Value = Array("그룹명", "입력숫자", "갯수", "마지막갯수 셀값") '// 헤더 서식 .Interior.Color = RGB(0, 0, 0) '// Black 배경 .Font.Color = RGB(255, 255, 255) '// White 글씨 .Font.Bold = True .HorizontalAlignment = xlCenter .VerticalAlignment = xlCenter '// 가는 선 테두리 .Borders.LineStyle = xlContinuous .Borders.Weight = xlThin End With '// 열 너비 자동 맞춤 ws.Columns("A:D").AutoFit ws.Range("A2").Resize(m, 4).Value = out Application.ScreenUpdating = True Exit Sub EH: MsgBox "오류 " & Err.Number & vbCrLf & Err.Description, vbCritical End Sub Private Function LeadNum(ByVal s As String) As Long '//' 첫 번째 "(" 앞의 숫자 추출. 실패 시 -1 Dim p As Long Dim t As String s = Trim$(s) If Len(s) = 0 Then LeadNum = -1 Exit Function End If p = InStr(1, s, "(", vbTextCompare) If p <= 1 Then LeadNum = -1 Exit Function End If t = Trim$(Left$(s, p - 1)) If Len(t) = 0 Then LeadNum = -1 ElseIf IsNumeric(t) Then LeadNum = CLng(t) Else LeadNum = -1 End If End Function
=LET(Area,I2:I10000, checkNum,2, arr,FILTER(Area,Area<>""), Data,SCAN("",arr,LAMBDA(a,b,IF(LEFT(b,1+len(checkNum))=checkNum&"(",IF(TAKE(a,-1)="",b,TAKE(a,-1)),""))), dd,UNIQUE(TOCOL(IF(Data="",NA(),Data),3)), MAP(dd,LAMBDA(m,SUM((Data=m)*1))) & MID(dd, 1+LEN(checkNum),100) )
감사합니다!!