Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Redefine UsedRange property of Worksheet Object

I am using the following code to loop through the UsedRange of worksheet:

For Each Cell In sh.UsedRange

I want to replace the .UsedRange property of the worksheet with a new range
via string variable called WorkingRange which has a new range address i it.
How do I do that?

Thanks

EM
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Redefine UsedRange property of Worksheet Object

Hi
Say WorkingRange is the address as a string

For Each Cell In sh.Range(WorkingRange).cells

Next

--
Regards,
Sébastien
<http://www.ondemandanalysis.com
<http://www.ready-reports.com


"ExcelMonkey" wrote:

I am using the following code to loop through the UsedRange of worksheet:

For Each Cell In sh.UsedRange

I want to replace the .UsedRange property of the worksheet with a new range
via string variable called WorkingRange which has a new range address i it.
How do I do that?

Thanks

EM

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default Redefine UsedRange property of Worksheet Object

If the new range address is a string, something like this might work for
you:
For each Cell in Range(WorkingRange)
HTH Otto
"ExcelMonkey" wrote in message
...
I am using the following code to loop through the UsedRange of worksheet:

For Each Cell In sh.UsedRange

I want to replace the .UsedRange property of the worksheet with a new
range
via string variable called WorkingRange which has a new range address i
it.
How do I do that?

Thanks

EM



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Redefine UsedRange property of Worksheet Object

Dim a variable of Type Range and Set the range you want to it before
executing the loop.

Dim Rng As Range
Dim Cel As Range
Set Rng = sh.UsedRange
For Each Cel In Rng
....
Next
.....
.....
Set Rng = Range(WorkingRange)
For Each Cel In Rng
...
Next

By the way, by "string variable called WorkingRange", I am assuming you
meant an assignment that looks like this... "A1:E5" (so that it would be
referenced as shown in my code by using it as the argument to the Range
command.

Rick


"ExcelMonkey" wrote in message
...
I am using the following code to loop through the UsedRange of worksheet:

For Each Cell In sh.UsedRange

I want to replace the .UsedRange property of the worksheet with a new
range
via string variable called WorkingRange which has a new range address i
it.
How do I do that?

Thanks

EM


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
Saving worksheet as CSV with correct usedrange... Mike Iacovou Excel Programming 1 November 14th 07 03:24 AM
Why is worksheet.usedrange empty? Sara Excel Worksheet Functions 2 August 24th 07 03:38 PM
Using The Value property of the ActiveCell object Almamba Excel Programming 3 February 21st 05 06:38 PM
Redefining the UsedRange of a Worksheet ExcelMonkey[_189_] Excel Programming 1 February 13th 05 06:34 PM
How to check if an object has a certain property? J Excel Programming 1 December 5th 04 11:58 AM


All times are GMT +1. The time now is 05:36 PM.

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"