Results 1 to 3 of 3

Remove Cells from a Range Object

Threaded View

  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    Salt Lake City, UT
    MS-Off Ver
    Excel 2010
    Posts
    24

    Remove Cells from a Range Object

    Hey all,

    I am attempting to remove certain cells from a range that I have previously defined. I've come up with a way to do this but I'm wondering if there's an easier way. Here is what I have:

    Dim startingRange As Range
    Dim subtractRange As Range
    Dim cell As Range
    Dim newRange As Range
    
    Set startingRange = Range("A1:A10")
    Set subtractRange = Range("A6:A10")
    Set newRange = Nothing
    
    For each cell in startingRange
    
    If intersect(cell,subtractRange) Is Nothing Then
    If newRange Is Nothing Then
    Set newRange = cell
    Else
    Set newRange = Union(newRange,cell)
    End If
    End If
    Next cell
    Like I said, this works but it seems like there should be a more efficient way. Any thoughts?
    Attached Files Attached Files
    Last edited by chris.c; 12-20-2012 at 02:39 PM. Reason: Typo; Attached workbook

Thread Information

Users Browsing this Thread

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

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