Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Defining Range of For Each Loop for Cells and Worksheets

I often use:

For Each Cell in Worksheet.UsedRange

My understanding is that you cannot alter the UsedRange
property as it is read only. Is it possible to define a
range up front and use this in conjuction with a For Each
Loop using Cell and Worksheet. Best case scenario my goal
would be to either use this range to limit the area
covered by the For Each loop. Or worse case scenario use
it to limit the actions undertakeh within the loop

Dim NewRange as Range
For Each Cell in Worksheet.Something????
Next

Or

Dim NewRange as Range
'Note NewRange would be a subst of .UsedRange

For Each Cell in Worksheet.UsedRange
If Cell.Address is within NewRange Then
do something
Next


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Defining Range of For Each Loop for Cells and Worksheets

In the context that you show, you are reading it!

--

HTH

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


"ExcelMonkey" wrote in message
...
I often use:

For Each Cell in Worksheet.UsedRange

My understanding is that you cannot alter the UsedRange
property as it is read only. Is it possible to define a
range up front and use this in conjuction with a For Each
Loop using Cell and Worksheet. Best case scenario my goal
would be to either use this range to limit the area
covered by the For Each loop. Or worse case scenario use
it to limit the actions undertakeh within the loop

Dim NewRange as Range
For Each Cell in Worksheet.Something????
Next

Or

Dim NewRange as Range
'Note NewRange would be a subst of .UsedRange

For Each Cell in Worksheet.UsedRange
If Cell.Address is within NewRange Then
do something
Next




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Defining Range of For Each Loop for Cells and Worksheets

if your data is like a database, perhaps

for each cell in Activesheet.Range("A1").CurrentRegion

Next cell


As a Test:
click in cell A1. Do Ctrl+Shift+8

does this select all the data you want to process? If so, that is the
current region.

--
Regards,
Tom Ogilvy

"ExcelMonkey" wrote in message
...
I often use:

For Each Cell in Worksheet.UsedRange

My understanding is that you cannot alter the UsedRange
property as it is read only. Is it possible to define a
range up front and use this in conjuction with a For Each
Loop using Cell and Worksheet. Best case scenario my goal
would be to either use this range to limit the area
covered by the For Each loop. Or worse case scenario use
it to limit the actions undertakeh within the loop

Dim NewRange as Range
For Each Cell in Worksheet.Something????
Next

Or

Dim NewRange as Range
'Note NewRange would be a subst of .UsedRange

For Each Cell in Worksheet.UsedRange
If Cell.Address is within NewRange Then
do something
Next




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
Defining a custom-named Range across several worksheets Sven Herremans Excel Worksheet Functions 3 October 23rd 07 12:23 PM
defining unique range of cells for different sheets as the same n. KSAPP Excel Discussion (Misc queries) 1 March 30th 05 07:18 PM
Drop down defining content of a range of cells philm13 Links and Linking in Excel 5 March 25th 05 03:31 PM
Defining a variable Range for cells with values in them! John Baker Excel Programming 1 January 19th 05 02:04 PM
Error 1004 when defining range by cells(r,c) format dave Excel Programming 8 May 18th 04 08:51 PM


All times are GMT +1. The time now is 11:43 AM.

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"