Help us understand the problem. What is going on with this article?

Javaコメントカウント(VBA資材)

備忘録
2020/02.24
単体コメントカウント

Option Explicit
Const Start_Row As Integer = 3
Const Start_Col As Integer = 2
Const Start_msg As String = "ここにスタートコメント"
Const End_msg As String = "ここにエンドコメント"

Sub Delコメントカウント()
Dim i As Integer
Dim MaxRow As Long
Dim DelCount As Long
Dim checkStr As String
Dim checkPoint As Boolean
checkPoint = False

' B列の最後行を取得
MaxRow = Range("B65536").End(xlUp).Row
For i = 3 To MaxRow
    checkStr = Cells(i, Start_Col).Value
    checkStr = Trim(checkStr)

'    スタートメッセージもしくは2周目の場合
    If checkStr = Start_msg Or checkPoint Then
        checkPoint = True
        checkStr = Left(checkStr, 1)

        ' /コメント判定
        If checkStr = "/" Then
        ' *コメント反映
        ElseIf checkStr = "*" Then
        ' 空白行判定
        ElseIf checkStr = "" Then
        Else
        ' 2周目フラグに真を設定
        ' カウント数インクリメントする
            DelCount = DelCount + 1
        End If
    End If

    ' エンドメッセージの場合
    If checkStr = End_msg Then
        ' 2周目フラグに偽を設定
        checkPoint = False
        ' スタート、エンドメッセージ分カウントを引く
        DelCount = DelCount - 2

    End If

Next i

MsgBox DelCount
End Sub
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした