View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default Selection of non-empty cells


Try like this:

note this will work only if the union will not get 'too complex'
e.g. will generate too many areas...


to get non-blank in column A:

dim rngF as range,rngC as range,rngR as range

on error resume next
set rngF = [a:a].specialcells(xlformulas)
set rngC = [a:a].specialcells(xlconstants)

if rngf is nothing then
if not rngC is nothing then
set rngR=rngC
end if
elseif rngC is nothing then
set rngR = rngF
else
set rngR = union(rngC,rngF)
endif

if not rngR is nothing then rngR.select

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Adrian wrote :

Hi,

How do I select all the non-empty cells in VBA code ?
Thanks.