View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Only step through cells that are "Active"

Winton,

You can use the UsedRange property to get a reference to the used
portion of the worksheet. E.g.,

Dim Rng As Range
For Each Rng In ActiveSheet.UsedRange.Cells
' do something with Rng
Next Rng



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"WintonCw" wrote in message
...
I need to write a macro that will perform an operation on every

cell on the page -- but only those in th earea I've worked in.
The one I've written now goes through all 65,000x65,000 cells
which I most definitely DON'T want to do! This is the loop I've
currently written -- how do I qualify it to stay within the
active range?

(btw--the range is variable, so I can't do something like:
For Each cell In Range(Cells(1, 1), Cells(20, 10))
)


Current loop:
For Each cell In Cells
...
next cell


Thank you so much!