View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Select all cells NOT in a range

Dim rng as Range, rng1 as Range, rng2 as Range
Set rng = MyRange
set rng1 = rng.specialcells(xlFormulas)
set rng2 = rng.Specialcells(xlconstants)
if not rng1 is nothing and not rng2 is nothing then
set rng = Union(rng1,rng2)
elseif not rng1 is nothing then
set rng = rng1
elseif not rng2 is nothing then
set rng = rng2
Else
set rng = nothing
end if
msgbox rng.Address

--
Regards,
Tom Ogilvy

"Rob" wrote in message
...
I'm trying to use SpecialCells to select all the non-blank cells in my

range.
If my approach is correct please tell me how to complete my code, or if
there's a better way...

'my approach is to:
set Blanks=MyRange.SpecialCells(xlCellTypeBlanks)
'and then
set MyRange=intersect ( MyRange , [not blanks] )

'but I can't work out how to get [not blanks]

Thanks in advance
Rob