View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Select All Cells Containing Data

Activesheet.UsedRange.Select

although this may select a larger area than you would expect. It represents
the smallest rectangular area that contains all the cells that Excel
considers it necessary to record information about. All cells outside this
area are essentially virtual until you use them. This setting doesn't always
compress however, just because you might clear or delete some cells.

If you have a contiguous area of filled cells, you might look at

Range("A1").Currentregion.Select


If a single column can be used to determine the extent of the data

Range("A1",cells(rows.count,1).End(xlup)).Resize(, 10).Select

If all values will be only constants (or only formulas), you might be able
to use one of the Specialcells options. Obviously, the more that is known
about the spreadsheet, the better a method can be tailored to return an
accurate result.

--
Regards,
Tom Ogilvy



"ajvasel" wrote:

What command can I use in my program to select all of the cells in a sheet
containing data despite frequent variances in the number of rows with data? I
can't seem to find it anywhere.