Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Colorindex referencing

I am looping thru thousands of rows copying the format from one to
another based on a certain condition.

Here is what I have now:
Cells(i, 8).Copy
Cells(j, 18).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False


How can I do this faster as it takes a lot of time to run.
How can I access the colorindex of a cell and use it to fill the target
cell?

Thanks
Steve

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Colorindex referencing

Range(A1:A1000).PasteSpecial Paste:=xlPasteFormats

--
Kind regards,

Niek Otten

"gtslabs" wrote in message
ups.com...
I am looping thru thousands of rows copying the format from one to
another based on a certain condition.

Here is what I have now:
Cells(i, 8).Copy
Cells(j, 18).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False


How can I do this faster as it takes a lot of time to run.
How can I access the colorindex of a cell and use it to fill the target
cell?

Thanks
Steve



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Colorindex referencing

But maybe that is no good as it copies the formats of all those cells
irrespective of the condition, whatever that condition is.

RBS

"Niek Otten" wrote in message
...
Range(A1:A1000).PasteSpecial Paste:=xlPasteFormats

--
Kind regards,

Niek Otten

"gtslabs" wrote in message
ups.com...
I am looping thru thousands of rows copying the format from one to
another based on a certain condition.

Here is what I have now:
Cells(i, 8).Copy
Cells(j, 18).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False


How can I do this faster as it takes a lot of time to run.
How can I access the colorindex of a cell and use it to fill the target
cell?

Thanks
Steve




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Colorindex referencing

True. It wasn't in the example, but if for each cell a condition has to be
tested, it does indeed get tedious.

--
Kind regards,

Niek Otten

"RB Smissaert" wrote in message
...
But maybe that is no good as it copies the formats of all those cells
irrespective of the condition, whatever that condition is.

RBS

"Niek Otten" wrote in message
...
Range(A1:A1000).PasteSpecial Paste:=xlPasteFormats

--
Kind regards,

Niek Otten

"gtslabs" wrote in message
ups.com...
I am looping thru thousands of rows copying the format from one to
another based on a certain condition.

Here is what I have now:
Cells(i, 8).Copy
Cells(j, 18).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False


How can I do this faster as it takes a lot of time to run.
How can I access the colorindex of a cell and use it to fill the target
cell?

Thanks
Steve






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Colorindex referencing

This is what I have but it still takes some time to run

showcolorindex = Cells(j, 8).Interior.ColorIndex
Cells(j, 18).Interior.ColorIndex = showcolorindex



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Colorindex referencing

This is what I have but it still takes some time to run

showcolorindex = Cells(j, 8).Interior.ColorIndex
Cells(j, 18).Interior.ColorIndex = showcolorindex

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Colorindex referencing

This is what I have but it still takes some time to run

showcolorindex = Cells(j, 8).Interior.ColorIndex
Cells(j, 18).Interior.ColorIndex = showcolorindex

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Colorindex referencing


Hello gtslabs,

You can speed the code up by copying the ColorIndex into an array
first. This seems counterintuitive to just making one to one
assignments. This code runs in 4 seconds on my machine. You can easily
adapt it to your needs.


Code:
--------------------

Sub CopyColors()

Dim ColorArray(10000) As Long
Dim R As Long

R = 0
For Each C In Range("H1:H10000")
R = R + 1
ColorArray(R) = C.Interior.ColorIndex
Next C

R = 0
For Each C In Range("R1:R10000")
R = R + 1
C.Interior.ColorIndex = ColorArray(R)
Next C

End Sub

--------------------


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=493171

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Colorindex referencing

Or maybe what you can do is copy all the values of the range that holds the
condition to be tested, use conditional formatting on the second range and
then make the values
disappear by setting the font to white.

RBS

"gtslabs" wrote in message
oups.com...
This is what I have but it still takes some time to run

showcolorindex = Cells(j, 8).Interior.ColorIndex
Cells(j, 18).Interior.ColorIndex = showcolorindex


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
colorindex Nell Fahey Excel Discussion (Misc queries) 3 April 28th 05 07:06 PM
ColorIndex Trevor Davidson Excel Programming 5 April 26th 04 10:39 PM
ColorIndex K Bro Excel Programming 2 February 7th 04 04:42 PM
ColorIndex K Bro Excel Programming 0 February 7th 04 03:30 PM


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