Excel (VBA)

Excel VBAに関するフォーラムです。
  • 解決済みのトピックにはコメントできません。
このトピックは解決済みです。
質問

 
(Windows 11 Pro : Excel 2021)
「全列5行目以降の()が無いセルの集計数」の ヘクセルさんへ
投稿日時: 23/03/05 17:09:47
投稿者: Nubo

早々に解決にされましたが、
 
自分で上げたサンプル(15:23:10)でtaitaniさんのコードを試してみましたか ?
私的には、違う気がします。
 
 
以下のコードで取り敢えず、15:23:10のケースでは「2」と表示されますが ?
 
但し、カッコは()は一組と判断して、(のみ検索
カッコが半角なのか、全角なのかは不明なので半角で統一、
 
なので以下のコードはコードとしては、不確実な点が多いです。
 
Option Explicit
 
Sub test()
 
    Dim SCnt1 As Long
    Dim lngRow As Long, lngCol As Long
    Dim LastRow As Long, LastCol As Long
    Dim Temp As String
    Dim ch1 As Long, ch2 As Long
     
    'LastRow = Cells(5, 1).End(xlDown).Row
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    'LastCol = Cells(5, 1).End(xlToRight).Row
    LastCol = Cells(5, Columns.Count).End(xlToLeft).Column
     
    For lngRow = 5 To LastRow
        For lngCol = 1 To LastCol
            Temp = Cells(lngRow, lngCol).Value
            ch1 = Len(Temp)
            ch2 = InStr(Temp, "(")
            If Temp <> "" Then
                If ch1 <> 1 And ch2 = 0 Then
                    SCnt1 = SCnt1 + 1
                End If
            Else
            End If
        Next
    Next
     
    MsgBox SCnt1
End Sub
 :?:

投稿日時: 23/03/05 17:16:16
投稿者: Nubo

すいません、質問がダブりました。
 
こちらは、無視して下さい。