ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Select only cells with data in them (https://www.excelbanter.com/excel-programming/345843-macro-select-only-cells-data-them.html)

[email protected]

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


Ron de Bruin

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




Bernie Deitrick

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




Bob Phillips[_6_]

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




[email protected]

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



All times are GMT +1. The time now is 06:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com