cara mendapatkan lastrow di sheet yang lain

  1. 4 bulan yang lalu

    saya ada code seperti di bawah

    Dim lastrw As Long, lastrwtab1 As Long, lastrwtab2 As Long, lastrwtab3 As Long, lastrwtab4 As Long
    Dim sht As String
    Dim shtname As Worksheet
    Dim tKeterangan As String
    Dim pos As Integer
    Dim sht1 As String
    Dim ws2 As Worksheet
    
    
    
    sht = Range("sName").Value
    Set shtname = Sheets(sht)
    lastrw = lastrow(shtname)
    'MsgBox sht
    
    sht1 = ActiveSheet.Name
    'MsgBox sht1
    Set ws2 = Sheets(sht1)
    
    
    Worksheets(sht).Activate
    'MsgBox shtname.Name
    For i = 4 To lastrw
        tKeterangan = shtname.Cells(i, 5).Value
        MsgBox tKeterangan
        pos = InStr(tKeterangan, "ok")
        If pos = 0 Then
            MsgBox "tidak ada"
        Else
    '        MsgBox "ada"
    '        Worksheets(sht1).Activate
            lastrwtab1 = ws2.ListObjects("Table1").Range.Rows.Count
            MsgBox lastrwtab1
        End If
        
    '    MsgBox i
    Next i

    saya mau mendapatkan lastrow dari beberapa table yang ada dalam 1 sheet di sht1 yaitu pada variable lastrwtab1
    tetapi selalu muncul error

 

atau Mendaftar untuk ikut berdiskusi!