+ Reply to Thread
Results 1 to 5 of 5

Get a range that is the difference between a range and UsedRange of a sheet

  1. #1
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Get a range that is the difference between a range and UsedRange of a sheet

    I am trying to get a range that is the difference between a range and the UsedRange of a sheet

    I get the error "Object variable or With block not set" and r.Select is highlighted?

    I have set r = DiffRngAndUsedRange(rng) which is a range not sure what my problem is

    Thanks

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Get a range that is the difference between a range and UsedRange of a sheet

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Get a range that is the difference between a range and UsedRange of a sheet

    Hello Nori, I get the same error, I can not see how your code is different

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Get a range that is the difference between a range and UsedRange of a sheet

    In the original code you had this which, if the 2 ranges don't intersect, will exit the function without returning anything.
    Please Login or Register  to view this content.
    I changed the code so it will return a union of the 2 ranges if they don't intersect.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Get a range that is the difference between a range and UsedRange of a sheet

    Thanks, I appreciate it

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help! - Copy Range (Sheet1,A10:F50), Paste Range (Sheet 2,A1:F41), Offset Range & Repeat
    By cjtimmer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-30-2015, 06:27 PM
  2. [SOLVED] usedrange doesn't reset when using 'application.activesheet.usedrange'
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2015, 10:39 PM
  3. Reset Active Range - VBA ActiveSheet.UsedRange does not work
    By wesc in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-07-2015, 06:47 AM
  4. [SOLVED] change the end of "usedrange" to the actual end of the used range :-)
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-24-2014, 06:37 AM
  5. [SOLVED] Set values only of range of previous sheet equal to range of original sheet
    By ozizushi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-22-2014, 12:13 PM
  6. Difference Between Range and Range.Value
    By googlebot in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2008, 10:28 AM
  7. UsedRange of a Range
    By JFamilo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-28-2005, 04:10 PM

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