Exclude one range from another

  • Thread starter Thread starter Charl
  • Start date Start date
C

Charl

I have two variables each defined as a Range say TotalRange and
SubRange. All the cells in SubRange fall within TotalRange.

Is there any way (without looping through the cells) to create a new
range from the above which contains all the cells in TotalRange which
do not fall into SubRange. (In other words the new range should be
TotalRange excluding SubRange)

Thanks
- Charl
 
I think it is possible
try this
Public Sub test()
'this removed data from subrange,that range will be blank
ActiveSheet.Range("subrange").ClearContents
'the nextline shifts the blanks to the last
ActiveSheet.Range("totalrange").Sort key1:=Range("a2")
End Sub
===========
 
Thanks, however I do not wish to delete the contents from SubRange - I
need to return a new range which contains TotalRange excluding SubRange
(all cell content needs to remain unchanged)

Regards
- Charl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top