Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default An interesting one for all you experts...

Hi All,

This might be an interesting one for the experts out there...

I have an Excel sheet with 50 columns and 50 rows. Each cell is colour coded
(background colour). i.e. White, Black, Red etc there is no data in the
cells...

I need to go through each cell on every row and column and place a number in
the cell according to which background colour the cell has... i.e.

White = 0
Black = 1
Red = 2
etc...

Is somebody can help me on this it would be very much appreciated, else I'm
gonna have to go and type all this into a table by hand... <violins :(
</violins)

Thanks again,
Andy



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default An interesting one for all you experts...


For Each cell In Selection
Select Case cell.Interior.Colorindex
Case 3: cell.Value = 2
Case 1: cell.Value = 1
Case xlColorindexNone: cell.Value = 0
End Select
Next cell

Select all the cells then run the code

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"EV" wrote in message
...
Hi All,

This might be an interesting one for the experts out there...

I have an Excel sheet with 50 columns and 50 rows. Each cell is colour

coded
(background colour). i.e. White, Black, Red etc there is no data in the
cells...

I need to go through each cell on every row and column and place a number

in
the cell according to which background colour the cell has... i.e.

White = 0
Black = 1
Red = 2
etc...

Is somebody can help me on this it would be very much appreciated, else

I'm
gonna have to go and type all this into a table by hand... <violins :(
</violins)

Thanks again,
Andy





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default An interesting one for all you experts...

Sub test()
Dim i As Long, j As Long

With ActiveSheet
For j = 1 To 50
For i = 1 To 50
Select Case .Cells(i, j).Interior.Color
Case vbWhite: .Cells(i, j).Value = 0
Case vbBlack: .Cells(i, j).Value = 1
Case vbRed: .Cells(i, j).Value = 2
End Select
Next
Next
End With
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"EV" wrote in message
...
Hi All,

This might be an interesting one for the experts out there...

I have an Excel sheet with 50 columns and 50 rows. Each cell is colour

coded
(background colour). i.e. White, Black, Red etc there is no data in the
cells...

I need to go through each cell on every row and column and place a number

in
the cell according to which background colour the cell has... i.e.

White = 0
Black = 1
Red = 2
etc...

Is somebody can help me on this it would be very much appreciated, else

I'm
gonna have to go and type all this into a table by hand... <violins :(
</violins)

Thanks again,
Andy





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default An interesting one for all you experts...


"Bob Phillips" wrote in message
...

Select all the cells then run the code

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)


You are an absolute star... Thank you for the quick reply...

It worked a treat...

Top man :)

Thanks
Andy


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default An interesting one for all you experts...

Is there a list of all the color indexes somwhere ... just so I can pick up
all the colors easily?

Thanks again
Andy




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default An interesting one for all you experts...

Look up Colorindex Property in VBA Help, and you will see them there.

Or else you could run this code snippet to see them. Run it on a blank
worksheet.

For i = 1 to 56
Cells(i,1).Interior.ColorIndex = i
Next

The row number gives the the index number

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"EV" wrote in message
...
Is there a list of all the color indexes somwhere ... just so I can pick

up
all the colors easily?

Thanks again
Andy




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default An interesting one for all you experts...


"Bob Phillips" wrote in message
...
Look up Colorindex Property in VBA Help, and you will see them there.

Or else you could run this code snippet to see them. Run it on a blank
worksheet.

For i = 1 to 56
Cells(i,1).Interior.ColorIndex = i
Next

The row number gives the the index number

--


that was pretty obvious really (duh !!! ) :)

Thanks Again... You been most helpfull...

Andy


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default An interesting one for all you experts...

Select the range and run this.

Sub NumbCol()
Dim c As Range
For Each c In Selection
c.Value = c.Interior.ColorIndex
Next c
End Sub


And to see all the colours with their colorindex

Sub ShowColor()
Dim c As Range, i As Integer
'select a cell in an empty column
Set c = ActiveCell
For i = 0 To 56
c.Offset(i, 0).Interior.ColorIndex = i
c.Offset(i, 1).Value = i
Next
End Sub


Regards Robert

"EV" wrote in message ...
Hi All,

This might be an interesting one for the experts out there...

I have an Excel sheet with 50 columns and 50 rows. Each cell is colour coded
(background colour). i.e. White, Black, Red etc there is no data in the
cells...

I need to go through each cell on every row and column and place a number in
the cell according to which background colour the cell has... i.e.

White = 0
Black = 1
Red = 2
etc...

Is somebody can help me on this it would be very much appreciated, else I'm
gonna have to go and type all this into a table by hand... <violins :(
</violins)

Thanks again,
Andy





---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.593 / Virus Database: 376 - Release Date: 21/02/2004


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
need help with an interesting chart jwhigham Charts and Charting in Excel 4 September 24th 09 05:14 PM
another interesting thing... Nick Dangr Excel Worksheet Functions 5 October 28th 05 12:53 AM
interesting question can anyone help short_n_curly Excel Discussion (Misc queries) 3 July 20th 05 09:02 PM
Most Interesting Problem I Had Ever Got. Ussiddiqui[_8_] Excel Programming 5 January 30th 04 12:37 PM


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