Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default UsedRange.Select - but is it?

Excel 2003 on XP

I have a worksheet containing one contiguous block of cells containing data,
which I wish to select.
If I use ActiveSheet.UsedRange.Select it often selects a range greater
than the block of cells - ie includes cells apparently containing no data.
What am I doing wrong?

--
donwb
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default UsedRange.Select - but is it?

There are different reasons cells can appear empty an not be empty. Test the
cell with isemty to determine is it is really empty. You could have spaces
in the cell which will look empty. You could have formulas in the cell that
is returning nothing.

Use this code to remove the empty cells

Sub remove()
Lastcol = Cells(1, Columns.Count).End(xlToLeft).Column
Set colrange = Range(Columns(Lastcol + 1), Columns(Columns.Count))
Columns(colrange.Address).Delete
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Rows((lastrow + 1) & ":" & Rows.Count).Delete
End Sub
"donbowyer" wrote:

Excel 2003 on XP

I have a worksheet containing one contiguous block of cells containing data,
which I wish to select.
If I use ActiveSheet.UsedRange.Select it often selects a range greater
than the block of cells - ie includes cells apparently containing no data.
What am I doing wrong?

--
donwb

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default UsedRange.Select - but is it?

If the block started in cell A1, then

Range("A1").CurrentRegion.Select

would be what I would try.

If you region is bounded by at least one truly emtpy row and column on the
sides (0r the borders of the sheet), then that should work.

--
Regards,
Tom Ogilvy


"donbowyer" wrote:

Excel 2003 on XP

I have a worksheet containing one contiguous block of cells containing data,
which I wish to select.
If I use ActiveSheet.UsedRange.Select it often selects a range greater
than the block of cells - ie includes cells apparently containing no data.
What am I doing wrong?

--
donwb

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default UsedRange.Select - but is it?

Hi Joel & Tom
I'm using both your suggestions now.
Many thanks
Don
--
donwb


"Tom Ogilvy" wrote:

If the block started in cell A1, then

Range("A1").CurrentRegion.Select

would be what I would try.

If you region is bounded by at least one truly emtpy row and column on the
sides (0r the borders of the sheet), then that should work.

--
Regards,
Tom Ogilvy


"donbowyer" wrote:

Excel 2003 on XP

I have a worksheet containing one contiguous block of cells containing data,
which I wish to select.
If I use ActiveSheet.UsedRange.Select it often selects a range greater
than the block of cells - ie includes cells apparently containing no data.
What am I doing wrong?

--
donwb

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
USEDRANGE ak Excel Programming 1 June 5th 06 05:07 AM
usedRange GC Excel Programming 2 March 31st 05 01:44 PM
usedrange Mike[_94_] Excel Programming 4 February 17th 05 03:59 PM
UsedRange Damien McBain Excel Programming 3 July 4th 04 01:55 PM
Usedrange Terry VanDuzee Excel Programming 6 August 10th 03 05:57 PM


All times are GMT +1. The time now is 11:49 PM.

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"