Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default macro code for grouping adjacent cells into one multi-line cel

Is there a way to automate the coloring of the text? For instance, in the
resulting cell with the formula:
=CONCATENATE( A1 , CHAR(10) , B1 , CHAR(10) , C1 )
Could the a1 value be red, the b1 value blue, and the c1 value green?
I've tried a macro that has:
ActiveCell.FormulaR1C1 =
"=CONCATENATE(RC[-3],CHAR(10),RC[-2],CHAR(10),RC[-1])"
but subsequent lines always end up with the values from the cells I'm using
to create the macro:
ActiveCell.FormulaR1C1 = "400" & Chr(10) & "5" & Chr(10) & "8484"
Any help you can provide will be most appreciated.
Thanks,
M John

"sebastienm" wrote:

Hi,
Go throught the following steps:
-Assuming the data is in cell A1, A2, A3
-using CHAR(10) to get a newline in the cell
- make sure the cell is formatted for 'wrap text':
menu FormatCell, tab Alignment, checkbox 'Wrap Text'
- formula
=CONCATENATE( A1 , CHAR(10) , B1 , CHAR(10) , C1 )
or
= A1 & CHAR(10) & B1 & CHAR(10) & C1

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


"M John" wrote:

I am trying to come up with a way to combine cells into one multi-line cell
via a macro or a combination of worksheet functions. I know about
"alt-enter" and vaguely understand "offset". Is there a way to do this?

example:
cell1 cell2 cell3 cell4
1
1 2 3 2
3
Many thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default macro code for grouping adjacent cells into one multi-line cel

- On a cell containing a formula, i don't think you can do it.
- If you copy/paste as value only, the formula is removed from the cell and
the value is kept, then you can do multiple coloring.
Try on the active cell (non-formula cell)
activecell.Characters(1,3).Font.ColorIndex=3

That is, as a summary of the whole process, you would have to do:
- Apply the concatenate formula to the range
- copy/paste special as value (to keep values only)
- loop through the whole range , cell by cell and color, something like:
activecell.Characters(1,3).Font.ColorIndex=3

Dim rg as Range, cell as range
Dim txtpos as long, txrlen as long

set rg= range("D3:D50")
for each cell in rg.cells
txtpos=1
txtlen=len(cell.offset(0,-3).text) 'length of text in A
cell.Characters(1,txtlen).Font.ColorIndex=3 'color in red
txtpos=txtpos + txtlen + 1 ' +1 for the newline character
txtlen=len(cell.offset(0,-2).text) 'length of text in B
cell.Characters(txtpos,txtlen).Font.ColorIndex=20 'search for blue, i
don't know
txtpos=txtpos + txtlen + 1 ' +1 for the newline character
txtlen=len(cell.offset(0,-1).text) 'length of text in C
cell.Characters(txtpos,txtlen).Font.ColorIndex=30 'search for green,
i don't know
next

Note: search for the color index. It correspond to your palette i believe
(menu ToolsOptions, tab COlor)
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"M John" wrote:

Is there a way to automate the coloring of the text? For instance, in the
resulting cell with the formula:
=CONCATENATE( A1 , CHAR(10) , B1 , CHAR(10) , C1 )
Could the a1 value be red, the b1 value blue, and the c1 value green?
I've tried a macro that has:
ActiveCell.FormulaR1C1 =
"=CONCATENATE(RC[-3],CHAR(10),RC[-2],CHAR(10),RC[-1])"
but subsequent lines always end up with the values from the cells I'm using
to create the macro:
ActiveCell.FormulaR1C1 = "400" & Chr(10) & "5" & Chr(10) & "8484"
Any help you can provide will be most appreciated.
Thanks,
M John

"sebastienm" wrote:

Hi,
Go throught the following steps:
-Assuming the data is in cell A1, A2, A3
-using CHAR(10) to get a newline in the cell
- make sure the cell is formatted for 'wrap text':
menu FormatCell, tab Alignment, checkbox 'Wrap Text'
- formula
=CONCATENATE( A1 , CHAR(10) , B1 , CHAR(10) , C1 )
or
= A1 & CHAR(10) & B1 & CHAR(10) & C1

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


"M John" wrote:

I am trying to come up with a way to combine cells into one multi-line cell
via a macro or a combination of worksheet functions. I know about
"alt-enter" and vaguely understand "offset". Is there a way to do this?

example:
cell1 cell2 cell3 cell4
1
1 2 3 2
3
Many thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default macro code for grouping adjacent cells into one multi-line cel

Works beautifully. The first time through, the result is: (for example)
2.1671.0339.604
but it's correctly colored. This is corrected by clicking on the cell as if
to edit it and then hit return, and it snaps to the:
2.167
1.033
9.604
which I can't explain, but I'm working to figure out.
Thank you so much for your help. It's most appreciated.

"sebastienm" wrote:

- On a cell containing a formula, i don't think you can do it.
- If you copy/paste as value only, the formula is removed from the cell and
the value is kept, then you can do multiple coloring.
Try on the active cell (non-formula cell)
activecell.Characters(1,3).Font.ColorIndex=3

That is, as a summary of the whole process, you would have to do:
- Apply the concatenate formula to the range
- copy/paste special as value (to keep values only)
- loop through the whole range , cell by cell and color, something like:
activecell.Characters(1,3).Font.ColorIndex=3

Dim rg as Range, cell as range
Dim txtpos as long, txrlen as long

set rg= range("D3:D50")
for each cell in rg.cells
txtpos=1
txtlen=len(cell.offset(0,-3).text) 'length of text in A
cell.Characters(1,txtlen).Font.ColorIndex=3 'color in red
txtpos=txtpos + txtlen + 1 ' +1 for the newline character
txtlen=len(cell.offset(0,-2).text) 'length of text in B
cell.Characters(txtpos,txtlen).Font.ColorIndex=20 'search for blue, i
don't know
txtpos=txtpos + txtlen + 1 ' +1 for the newline character
txtlen=len(cell.offset(0,-1).text) 'length of text in C
cell.Characters(txtpos,txtlen).Font.ColorIndex=30 'search for green,
i don't know
next

Note: search for the color index. It correspond to your palette i believe
(menu ToolsOptions, tab COlor)
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"M John" wrote:

Is there a way to automate the coloring of the text? For instance, in the
resulting cell with the formula:
=CONCATENATE( A1 , CHAR(10) , B1 , CHAR(10) , C1 )
Could the a1 value be red, the b1 value blue, and the c1 value green?
I've tried a macro that has:
ActiveCell.FormulaR1C1 =
"=CONCATENATE(RC[-3],CHAR(10),RC[-2],CHAR(10),RC[-1])"
but subsequent lines always end up with the values from the cells I'm using
to create the macro:
ActiveCell.FormulaR1C1 = "400" & Chr(10) & "5" & Chr(10) & "8484"
Any help you can provide will be most appreciated.
Thanks,
M John

"sebastienm" wrote:

Hi,
Go throught the following steps:
-Assuming the data is in cell A1, A2, A3
-using CHAR(10) to get a newline in the cell
- make sure the cell is formatted for 'wrap text':
menu FormatCell, tab Alignment, checkbox 'Wrap Text'
- formula
=CONCATENATE( A1 , CHAR(10) , B1 , CHAR(10) , C1 )
or
= A1 & CHAR(10) & B1 & CHAR(10) & C1

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


"M John" wrote:

I am trying to come up with a way to combine cells into one multi-line cell
via a macro or a combination of worksheet functions. I know about
"alt-enter" and vaguely understand "offset". Is there a way to do this?

example:
cell1 cell2 cell3 cell4
1
1 2 3 2
3
Many thanks in advance.

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
Macro code to put series name next to individual line in line grap Otani Charts and Charting in Excel 3 February 23rd 10 07:24 PM
Concatenate: Multi-Line Cell with 2 single line cells BEEJAY Excel Worksheet Functions 0 February 15th 07 08:53 PM
Reusing grouping of non-adjacent cells [email protected] Excel Discussion (Misc queries) 2 May 28th 06 01:21 PM
macro code for grouping adjacent cells into one multi-line cel M John Excel Programming 0 November 29th 05 11:54 PM
how can I paste multi-line/multi-paragraph data into ONE cell? Theano Excel Discussion (Misc queries) 3 June 7th 05 01:10 PM


All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"