VBA - Range.Row.Count

前端 未结 10 1520
别那么骄傲
别那么骄傲 2020-12-24 13:23

I have written a simple code to illustrate my predicament.

Sub test()
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets(\"Sheet1\")

    Dim k As Lon         


        
10条回答
  •  自闭症患者
    2020-12-24 13:52

    Have you tried :-

    Sub test()
    
        k = Cells(Rows.Count, "A").End(xlUp).Row
    
        MsgBox (k)
    
    End Sub
    

    The /only/ catch is that if there is no data it still returns 1.

提交回复
热议问题