Results 1 to 4 of 4

Runtime Error 91: Object variable or With block variable not set

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    Runtime Error 91: Object variable or With block variable not set

    Hi all,
    I have a macro that performs filtering and deleting unwanted rows.
    I find it strange that it is now not working when it was working few days ago.
    It's giving me a runtime error 91.

    Here's my code:

    Sub Testing()
        
        Dim Cl     As Range
        Dim rng    As Range
        Dim R      As Long
        Dim X      As Long
    
        R = ActiveSheet.Cells(Rows.Count, "K").End(xlUp).Row
        For X = 2 To R
            If Cells(X, "K").Value <> "AB," And Cells(X, "K").Value <> "CD," And _
             Cells(X, "K").Value <> "EF," And Cells(X, "K").Value <> "IJ," And Cells(X, "K").Value <> "TU," Then
                If rng Is Nothing Then
                    Set rng = Cells(X, "K")
                Else: Set rng = Union(rng, Cells(X, "K"))
                End If
            End If
        Next X
        
        rng.EntireRow.Delete
    
    
    End Sub
    Any ideas? Appreciate any help. Thank you.
    Last edited by Andrew.Trevayne; 06-21-2018 at 09:09 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 05-19-2016, 05:12 AM
  2. Runtime Error 91 Object Variable or With Block not Set
    By wkddj51 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-28-2015, 06:05 AM
  3. Runtime Error 91 - object variable or with block variable not set
    By 0celj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2013, 09:40 PM
  4. runtime error 91 object variable or With block variable not set
    By tullemann in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2011, 01:27 PM
  5. Replies: 8
    Last Post: 02-17-2009, 02:24 PM
  6. Runtime error 91 - Object variable or with block variable not set
    By Christian411 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-04-2008, 08:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1