Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Is there a better way to get Range of cells for entier worksheet ?

I am wondering if there is a quick easy way to set a range for all the cells
in a worksheet. for example..

Set X = Range("Sheet1")

I want to run a conditional statement on each cell in my work sheet somthing
like ...

For each cel in (x) if cel.interiorcolor = 5 Then (run this code)

I would rather use somthing like Set X = Range("Sheet1") than have to
do something like

Set X = Range("Sheet1").cells(1,1) to (65536, 256)

Any thoughts please ?

Thanks Dan
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Is there a better way to get Range of cells for entier worksheet ?

Hi Dan,

Set x = Sheets("Sheet1").Cells

but I wonder why you want to test the entire worksheet. The following sets
the used range on the worksheet.

Set x = Sheets("Sheet1").UsedRange

--
Regards,

OssieMac


"Dan Thompson" wrote:

I am wondering if there is a quick easy way to set a range for all the cells
in a worksheet. for example..

Set X = Range("Sheet1")

I want to run a conditional statement on each cell in my work sheet somthing
like ...

For each cel in (x) if cel.interiorcolor = 5 Then (run this code)

I would rather use somthing like Set X = Range("Sheet1") than have to
do something like

Set X = Range("Sheet1").cells(1,1) to (65536, 256)

Any thoughts please ?

Thanks Dan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Is there a better way to get Range of cells for entier worksheet ?

I thought my question needed to be simpler so here is my working code what it
does is checks all cells in the active worksheet for any cells colored Cyan
if there are it replaces thoes cell with the "no fill" color the problem is
when I run the code it works but is VERY VERY slow and takes forever to
finish running on one sheet.

Dim EntireSheet As Range, cel As Range

With ActiveSheet
Set EntireSheet = Range(.Cells(1, 1), .Cells(65536, 256))
For Each cel In EntireSheet
If cel.Interior.ColorIndex = 8 Then cel.Interior.ColorIndex = xlNone
Next cel
End With

Is there a more efficient way of doing this ??

Dan

"Dan Thompson" wrote:

I am wondering if there is a quick easy way to set a range for all the cells
in a worksheet. for example..

Set X = Range("Sheet1")

I want to run a conditional statement on each cell in my work sheet somthing
like ...

For each cel in (x) if cel.interiorcolor = 5 Then (run this code)

I would rather use somthing like Set X = Range("Sheet1") than have to
do something like

Set X = Range("Sheet1").cells(1,1) to (65536, 256)

Any thoughts please ?

Thanks Dan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Is there a better way to get Range of cells for entier workshe

OssieMAc answered....

For Each cel In ActiveSheet.UsedRange
If cel.Interior.ColorIndex = 8 Then cel.Interior.ColorIndex = xlNone
Next cel







"Dan Thompson" wrote:

I thought my question needed to be simpler so here is my working code what it
does is checks all cells in the active worksheet for any cells colored Cyan
if there are it replaces thoes cell with the "no fill" color the problem is
when I run the code it works but is VERY VERY slow and takes forever to
finish running on one sheet.

Dim EntireSheet As Range, cel As Range

With ActiveSheet
Set EntireSheet = Range(.Cells(1, 1), .Cells(65536, 256))
For Each cel In EntireSheet
If cel.Interior.ColorIndex = 8 Then cel.Interior.ColorIndex = xlNone
Next cel
End With

Is there a more efficient way of doing this ??

Dan

"Dan Thompson" wrote:

I am wondering if there is a quick easy way to set a range for all the cells
in a worksheet. for example..

Set X = Range("Sheet1")

I want to run a conditional statement on each cell in my work sheet somthing
like ...

For each cel in (x) if cel.interiorcolor = 5 Then (run this code)

I would rather use somthing like Set X = Range("Sheet1") than have to
do something like

Set X = Range("Sheet1").cells(1,1) to (65536, 256)

Any thoughts please ?

Thanks Dan



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Is there a better way to get Range of cells for entier workshe

Your code work Patrick but unfortunitly it is still just as slow as mine and
takes forever to finish

"Patrick Molloy" wrote:

OssieMAc answered....

For Each cel In ActiveSheet.UsedRange
If cel.Interior.ColorIndex = 8 Then cel.Interior.ColorIndex = xlNone
Next cel







"Dan Thompson" wrote:

I thought my question needed to be simpler so here is my working code what it
does is checks all cells in the active worksheet for any cells colored Cyan
if there are it replaces thoes cell with the "no fill" color the problem is
when I run the code it works but is VERY VERY slow and takes forever to
finish running on one sheet.

Dim EntireSheet As Range, cel As Range

With ActiveSheet
Set EntireSheet = Range(.Cells(1, 1), .Cells(65536, 256))
For Each cel In EntireSheet
If cel.Interior.ColorIndex = 8 Then cel.Interior.ColorIndex = xlNone
Next cel
End With

Is there a more efficient way of doing this ??

Dan

"Dan Thompson" wrote:

I am wondering if there is a quick easy way to set a range for all the cells
in a worksheet. for example..

Set X = Range("Sheet1")

I want to run a conditional statement on each cell in my work sheet somthing
like ...

For each cel in (x) if cel.interiorcolor = 5 Then (run this code)

I would rather use somthing like Set X = Range("Sheet1") than have to
do something like

Set X = Range("Sheet1").cells(1,1) to (65536, 256)

Any thoughts please ?

Thanks Dan

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
Best Substitute for Range(cells(),cells()) in worksheet Matthew Pfluger Excel Programming 1 February 7th 08 03:51 PM
Pop Up Calendar for entier workbook Klee Excel Worksheet Functions 0 July 28th 07 02:38 PM
Unlocking range of cells/worksheet? DJone Excel Discussion (Misc queries) 1 April 18th 07 06:50 PM
cells name or range name in a worksheet Jean-Pierre Bidon Excel Programming 1 February 1st 06 11:23 AM
is there a way to protect a range of cells on a worksheet? vevans Excel Discussion (Misc queries) 1 February 17th 05 05:30 PM


All times are GMT +1. The time now is 12:01 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"