Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Macro Select only cells with data in them

How do I ask a macro to only select the cells in a specific range, like
say A1:G2000, to select only till those rows, where there is data and
leave the blanks? This, I need to reduce the workbook size...

Please advise

Sunny

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro Select only cells with data in them

Hi Sunny

You can use activesheet.Usedrange for this maybe

See this page to reset your usedrange
http://www.contextures.com/xlfaqApp.html#Unused

--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message oups.com...
How do I ask a macro to only select the cells in a specific range, like
say A1:G2000, to select only till those rows, where there is data and
leave the blanks? This, I need to reduce the workbook size...

Please advise

Sunny



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Macro Select only cells with data in them

Sunny,

If the cells are filled with data (and not formulas):

Range("A1:G2000").SpecialCells(xlCellTypeConstants ).Select

Explain a little more of what you want to do, and we can help further.

HTH,
Bernie
MS Excel MVP


wrote in message
oups.com...
How do I ask a macro to only select the cells in a specific range, like
say A1:G2000, to select only till those rows, where there is data and
leave the blanks? This, I need to reduce the workbook size...

Please advise

Sunny



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro Select only cells with data in them

Sammy,

Here is one way

Const sRange As String = "A1:G2000"
Dim saveSet
Dim rng As Range
saveSet = Range(sRange).Formula
Set rng = Range(sRange).SpecialCells(xlCellTypeBlanks)
Range(sRange).ClearContents
rng = 0
Set rng = Range(sRange).SpecialCells(xlCellTypeBlanks)
Range(sRange) = saveSet
rng.Select

--

HTH

RP
(remove nothere from the email address if mailing direct)


wrote in message
oups.com...
How do I ask a macro to only select the cells in a specific range, like
say A1:G2000, to select only till those rows, where there is data and
leave the blanks? This, I need to reduce the workbook size...

Please advise

Sunny



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Macro Select only cells with data in them

Thanks All!

My requirement was pretty basic..Just that I recorded a macro to sort
data which can go upto 3000 rows, but in cases where lesser rows have
content, I didn't want unnecessary file size increase...This works fine
now!

Thanks again

Sunny



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
Macro to select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
Macro to select cells in column enter data then press enter NP New Users to Excel 1 February 20th 08 04:21 PM
need a macro select all cells in a worksheet? MarkN Excel Discussion (Misc queries) 0 June 23rd 06 12:47 AM
Macro to select various cells DSC174 Excel Programming 1 September 26th 05 04:48 PM
Select other workbook to select data in a macro. T Tromp Excel Programming 2 September 19th 03 01:43 PM


All times are GMT +1. The time now is 07:00 AM.

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

About Us

"It's about Microsoft Excel"