#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Cell Select

A row cells A1 to W1 contains text in a selection of them. If various cells
have the background color highlighted blue, is it possible for the text in
the coloured cells to be put in a single cell F7 and seperated by a comma.

Many thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Cell Select

A macro like this could be used to do it:

Sub IDbyColor()
Dim ContentsOfAll As String
Dim WhatColorCode As Integer
Dim anyCell As Object

WhatColorCode = 41 ' light blue
For Each anyCell In Range("A1:W1")
If anyCell.Interior.ColorIndex = WhatColorCode Then
ContentsOfAll = ContentsOfAll & anyCell.Text & ","
End If
Next
If Right(ContentsOfAll, 1) = "," Then
ContentsOfAll = Left(ContentsOfAll, Len(ContentsOfAll) - 1)
End If
Range("F7") = ContentsOfAll

End Sub

You'd need to know the specific code for the fill color/shade of blue
chosen. That could be determined by recording a macro to set a cell's
shading to the color and examining the created macro to see what value was
used.

The UDF (user defined function) version of it:
Public Function ListColoredCellContents()
Dim ContentsOfAll As String
Dim WhatColorCode As Integer
Dim anyCell As Object

Application.Volatile
WhatColorCode = 41 ' light blue
For Each anyCell In Range("A1:W1")
If anyCell.Interior.ColorIndex = WhatColorCode Then
ContentsOfAll = ContentsOfAll & anyCell.Text & ","
End If
Next
If Right(ContentsOfAll, 1) = "," Then
ContentsOfAll = Left(ContentsOfAll, Len(ContentsOfAll) - 1)
End If
ListColoredCellContents = ContentsOfAll
End Function

You can use that in F7 like:
=ListColoredCellContents()

Since it will not be updated just by changing cell shading, you'd need to use
[Ctrl]+[Alt]+[F9] to insure that the information displayed in F7 (or any
place else you'd used the UDF) is current.


"zephyr" wrote:

A row cells A1 to W1 contains text in a selection of them. If various cells
have the background color highlighted blue, is it possible for the text in
the coloured cells to be put in a single cell F7 and seperated by a comma.

Many thanks

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Cell Select

Functional workbook with both methods included:
http://www.jlathamsite.com/uploads/for_zephyr.xls

Instructions for adding code to a workbook:
http://www.jlathamsite.com/Teach/Excel_GP_Code.htm
or at Debra Dalgleish's site
http://www.contextures.com/xlvba01.html

"zephyr" wrote:

A row cells A1 to W1 contains text in a selection of them. If various cells
have the background color highlighted blue, is it possible for the text in
the coloured cells to be put in a single cell F7 and seperated by a comma.

Many thanks

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Cell Select

Dear Mr Latham

Thank you for the download on you're website.

You're assistance is appreciated.

Many thanks

Zephyr

"JLatham" wrote:

Functional workbook with both methods included:
http://www.jlathamsite.com/uploads/for_zephyr.xls

Instructions for adding code to a workbook:
http://www.jlathamsite.com/Teach/Excel_GP_Code.htm
or at Debra Dalgleish's site
http://www.contextures.com/xlvba01.html

"zephyr" wrote:

A row cells A1 to W1 contains text in a selection of them. If various cells
have the background color highlighted blue, is it possible for the text in
the coloured cells to be put in a single cell F7 and seperated by a comma.

Many thanks

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default Cell Select

I hope it helps some. Sometimes there's just nothing like a working example
to let someone see how it actually works in the real world.

"zephyr" wrote:

Dear Mr Latham

Thank you for the download on you're website.

You're assistance is appreciated.

Many thanks

Zephyr

"JLatham" wrote:

Functional workbook with both methods included:
http://www.jlathamsite.com/uploads/for_zephyr.xls

Instructions for adding code to a workbook:
http://www.jlathamsite.com/Teach/Excel_GP_Code.htm
or at Debra Dalgleish's site
http://www.contextures.com/xlvba01.html

"zephyr" wrote:

A row cells A1 to W1 contains text in a selection of them. If various cells
have the background color highlighted blue, is it possible for the text in
the coloured cells to be put in a single cell F7 and seperated by a comma.

Many thanks

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
insert date Larry Excel Worksheet Functions 28 July 15th 06 02:41 AM
How to point to (select) a cell to the left from a cell where I enter the = equal sign? Dmitry Excel Discussion (Misc queries) 4 June 30th 06 06:49 AM
Select cell, Copy it, Paste it, Return to Previous cell spydor Excel Discussion (Misc queries) 1 December 30th 05 01:29 PM
enhanced conditional formatting Stuart Excel Discussion (Misc queries) 13 November 13th 05 07:20 PM
select a cell and the one next to it Donna S Excel Discussion (Misc queries) 3 November 4th 05 06:53 PM


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