Count lines (max) with values

后端 未结 2 568
梦毁少年i
梦毁少年i 2021-01-26 07:43

I would like to count the lines that have values. I tried oSheet.Rows.Count but that doesn\'t work. Any idea about this?

My code is the following:

2条回答
  •  有刺的猬
    2021-01-26 08:40

    Define a row variable as Long, then start a loop which will end when it finds a blank value in column A:

    Dim lRow as Long = 1
    
    Do until oSheet.Range("A" & lRow).Value=""
      ' increment the loop variable
      lRow+=1
    Loop
    
    ' display the result in a message block
    MsgBox(lRow-1)
    

提交回复
热议问题