Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Select All Cells Containing Data

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default Select All Cells Containing Data


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.


try:

Cells.Select

  #3   Report Post  
Posted to microsoft.public.excel.programming
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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Select All Cells Containing Data

Thanks, Tom - I am trying the first suggestion right now. My spreadsheet
contains data in columns A - V (roughly 2,000 rows of data starting on row
4). Just about every cell contains data but not all. The
Activesheet.UsedRange.Select appears to have worked just as I needed though.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Select All Cells Containing Data

that selects all the cells in the sheet for me - regardless of whether they
contain data or not.

--
Regards,
Tom Ogilvy


"stevebriz" wrote:


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.


try:

Cells.Select




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Select All Cells Containing Data

To further expand on this question, is it possible to select all of the cells
of a specific column when some of the cells in said column are blank.

I tried selecting a range greater than the cells containing data and used
control-shift-up, but in the next section of the code where I add a border,
it added a border around the entire column.

(example):
Range("K4:K4000").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With

Thanks
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Select All Cells Containing Data

Range("K4:K4000").Select
Range("K4", Cells(rows.count,"K").End(xlUp)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With


--
regards,
Tom Ogilvy

"ajvasel" wrote:

To further expand on this question, is it possible to select all of the cells
of a specific column when some of the cells in said column are blank.

I tried selecting a range greater than the cells containing data and used
control-shift-up, but in the next section of the code where I add a border,
it added a border around the entire column.

(example):
Range("K4:K4000").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With

Thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Select All Cells Containing Data

Thanks, Tom, that was just what I needed.

"Tom Ogilvy" wrote:

Range("K4:K4000").Select
Range("K4", Cells(rows.count,"K").End(xlUp)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With


--
regards,
Tom Ogilvy

"ajvasel" wrote:

To further expand on this question, is it possible to select all of the cells
of a specific column when some of the cells in said column are blank.

I tried selecting a range greater than the cells containing data and used
control-shift-up, but in the next section of the code where I add a border,
it added a border around the entire column.

(example):
Range("K4:K4000").Select
Range(Selection, Selection.End(xlUp)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 3
End With

Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Up down arrow keys do not select cells if select locked cells unch roandrob Excel Discussion (Misc queries) 3 May 18th 09 12:48 AM
How do you select all text/data within all the cells of a column? VisionsIC Excel Discussion (Misc queries) 3 December 20th 08 02:36 AM
Select data from cells Luis Excel Discussion (Misc queries) 5 June 15th 06 10:21 PM
Select Cells In Column that have data Sean[_15_] Excel Programming 4 May 15th 06 04:56 PM
Macro Select only cells with data in them [email protected] Excel Programming 4 November 17th 05 08:10 PM


All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"