ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UsedRange & Formatting of Cells (https://www.excelbanter.com/excel-programming/280623-usedrange-formatting-cells.html)

JStone0218

UsedRange & Formatting of Cells
 
When I use the code below, the shading of the cells in column A impact the
UsedRange. Is this normal?

For Each cell In ActiveSheet.UsedRange.Columns(1).Rows


Robert Rosenberg[_2_]

UsedRange & Formatting of Cells
 
Yes, cell shading constitutes part of the UsedRange

--
_______________________
Robert Rosenberg
R-COR Consulting Services
Microsoft MVP - Excel
"JStone0218" wrote in message
...
When I use the code below, the shading of the cells in column A impact the
UsedRange. Is this normal?

For Each cell In ActiveSheet.UsedRange.Columns(1).Rows




Robert Rosenberg[_2_]

UsedRange & Formatting of Cells
 
Accidentally hit Ctrl+Enter and sent my other response prematurely.

You can refine your code as follows:

For Each cell In
ActiveSheet.UsedRange.Columns(1).SpecialCells(xlCe llTypeConstants).Rows.Addr
ess

This assumes that column 1 has constant and not formulas. If they contain
formulas, use xlCellTypeFormulas. If they contain both, you'll need to use a
range variable and define it for both using "Union".
--
_______________________
Robert Rosenberg
R-COR Consulting Services
Microsoft MVP - Excel
"JStone0218" wrote in message
...
When I use the code below, the shading of the cells in column A impact the
UsedRange. Is this normal?

For Each cell In ActiveSheet.UsedRange.Columns(1).Rows




JStone0218

UsedRange & Formatting of Cells
 
Robert,

Thanks for the quick response. I followed your recomendation and it works
great!

James

You can refine your code as follows:

For Each cell In
ActiveSheet.UsedRange.Columns(1).SpecialCells(xlC ellTypeConstants).Rows.Addr
ess

This assumes that column 1 has constant and not formulas. If they contain
formulas, use xlCellTypeFormulas. If they contain both, you'll need to use a
range variable and define it for both using "Union".
--
_______________________
Robert Rosenberg
R-COR Consulting Services
Microsoft MVP - Excel
"JStone0218" wrote in message
...
When I use the code below, the shading of the cells in column A impact the
UsedRange. Is this normal?

For Each cell In ActiveSheet.UsedRange.Columns(1).Rows




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

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