menjumlahkan var dengan value cell

  1. 3 tahun lalu

    mau tanya kenapa selalu muncul runtime error "91" : Object variable or with block variable not set

    ini sample codenya :

    If iFind Is Nothing Then
       Set iFind = WipCodeInvES01.Find(what:=WIPCode, _
                                                            After:=WipCodeInvES01("6"), _
                                                            LookIn:=xlValues, _
                                                            Lookat:=xlPart, _
                                                            SearchOrder:=xlByRows, _
                                                            SearchDirection:=xlNext, _
                                                            MatchCase:=False)
                                If iFind Is Nothing Then
                                    With wsWIPConsumption
                                        .Cells(r, 7).Value = "0"
                                        .Cells(r, 8).Value = "0"
                                    End With
                                End If
        Set sel = iFind
    else
       Set sel = WIPCodeInv.Find(what:=WIPCode, _
                                                                After:=sel, _
                                                                LookIn:=xlValues, _
                                                                Lookat:=xlPart, _
                                                                SearchOrder:=xlByRows, _
                                                                SearchDirection:=xlNext, _
                                                                MatchCase:=False)
                                If sel Is Nothing Then
                                    With wsWIPConsumption
                                        .Cells(r, 7).Value = "0"
                                        .Cells(r, 8).Value = "0"
                                    End With
                                End If
                                                            
                            End If
                            If sel.Address = iFind.Address Then Exit Do
                        End If
    
                            Select Case iSht.Name
                            Case Is = "A"
                                JumQty = JumQty + iSht.Cells(sel.Row, 21).Value
                                JumAmount = JumAmount + iSht.Cells(sel.Row, 22).Value
                            Case Is = "B"
                                JumQty = JumQty + iSht.Cells(sel.Row, 31).Value
                                JumAmount = JumAmount + iSht.Cells(sel.Row, 32).Value
                            Case Is = "C"
                                JumQty = JumQty + iSht.Cells(sel.Row, 29).Value
                                JumAmount = JumAmount + iSht.Cells(sel.Row, 30).Value
                            


    A B C
    243110001 A 3
    243110002 A 5
    243110003 B 5
    243110004 B 7
    243130005 B Error
    243140006 C
    243150007 C
    211110008 C

    jadi saya ingin mengambil nilai C pada 1 file yg mempunyai banyak sheet saya misalkan Sheet A sampai Sheet C
    pada saat di tengah proses untuk mengambil nilai di sheet B ada muncul error runtime "91" dan code berhenti di jumQty.

    apa ada yang bisa bantu

  2. Masdad

    21 Okt 2020 Terverifikasi Demak + 2.198 Poin
    Di sunting 3 tahun lalu oleh Masdad

    Runtime error "91" : Object variable or with block variable not set artinya ada tipe data object yang belum dilakukan set, tinggal di cari saja object mana yang belum di set, bisa range, sel atau sheet atau object lainnya.

  3. utk jumqty tipenya bukan range tapi long yg agak aneh itu errornya pd saat di tengah proses B dimana proses B yg sebelumnya ke ambil datanya..

  4. tghfox

    27 Okt 2020 Terverifikasi Bekasi Barat + 579 Poin

    @Masdad Runtime error "91" : Object variable or with block variable not set artinya ada tipe data object yang belum dilakukan set, tinggal di cari saja object mana yang belum di set, bisa range, sel atau sheet atau object lainnya.

    nah benar ini, kalo dilihat codenya sepertinya ada gagal di saat pencarian set iFind atau sel = blabla
    berikut contoh alternatif pencarian, agak tricky pakai on error resume next

 

atau Mendaftar untuk ikut berdiskusi!