Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8447731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:15:12+00:00 2026-06-10T10:15:12+00:00

Suppose I have some module in vba with some variable r of type Range

  • 0

Suppose I have some module in vba with some variable r of type Range. Suppose that, at some point, I store a Range object there (e.g. the active cell). Now my question: What happens to the value of r if the user deletes the cell (the cell, not only its value)?

I tried to figure this out in VBA, but without success. The result is strange. r is not Nothing, the value of r is reported to be of type Range, but if I try to look at its properties in the debugger window, each property’s value is reported as “object required”.

How can I, programmatically, determine whether variable r is in this state or not?

Can I do this without generating an error and catching it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:15:14+00:00Added an answer on June 10, 2026 at 10:15 am

    Nice question! I’ve never thought about this before, but this function will, I think, identify a range that was initialzed – is not Nothing – but is now in the “Object Required” state because its cells were deleted:

    Function RangeWasDeclaredAndEntirelyDeleted(r As Range) As Boolean
    Dim TestAddress As String
    
    If r Is Nothing Then
        Exit Function
    End If
    On Error Resume Next
    TestAddress = r.Address
    If Err.Number = 424 Then    'object required
        RangeWasDeclaredAndEntirelyDeleted = True
    End If
    End Function
    

    You can test is like this:

    Sub test()
    Dim r As Range
    
    Debug.Print RangeWasDeclaredAndEntirelyDeleted(r)
    Set r = ActiveSheet.Range("A1")
    Debug.Print RangeWasDeclaredAndEntirelyDeleted(r)
    r.EntireRow.Delete
    Debug.Print RangeWasDeclaredAndEntirelyDeleted(r)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Propose to consider the following problem. Suppose we have some composite object. Are there
Suppose I have some class which has a property actor_ of type Actor .
Lets suppose that I have some pages some.web/articles/details/5 some.web/users/info/bob some.web/foo/bar/7 that can call a
Suppose I have a Collection of some kind that itself contains Collections; e.g., Dictionary(Of
Suppose I have a module which defines some basic constants such as integer, parameter
Suppose, I have 3 stores. I want to disable a module in Store 2.
Suppose I have a DLL that exports some functions and I know an address
Suppose I have the following string: http://earth.google.com/gallery/kmz/women_for_women.kmz?a=large Is there some function or module to
I am working on a Python module that suppose to checkout some code from
Suppose you have some complex JSON like: {A : valA, B : { C

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.