Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Combine data in cells

Hi, I'm trying to write a macro that will combine the contents of 2 cells in
to one with a line feed between each.

I tried to use vblf or chr(10) but it doesn't work.

ActiveCell.Formula = "=$n$1&H5" & vbLf & "$0$1&H4"

Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Combine data in cells

Bob, Thank you for your help. However, the formula does not enter a "line
feed" to pull down to the next line. It appears as wrapped text:

1)Incorrect maturity date on TIL2)Incorrect
maturity date on Note

I've also tried chr(13) in place of chr(10) but I get a runtime error when I
use that.

I have the 1) in cell n1 the 2) in cell o1 and text in cells H4 and H5. I
want it to appear as:

1)Incorrect maturity date on TIL
2)Incorrect maturity date on Note

all in the same cell.

Thanks in advance.

"Bob Phillips" wrote:

With ActiveCell
.Formula = "=R1C14&R[" & 5 - .Row & "]C[" & 8 - .Column & "]&" & _
Chr(10) & "R1C15&R[" & 4 - .Row & "]C[" & 8 - .Column &
"]"
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"xgirl" wrote in message
...
Hi, I'm trying to write a macro that will combine the contents of 2 cells

in
to one with a line feed between each.

I tried to use vblf or chr(10) but it doesn't work.

ActiveCell.Formula = "=$n$1&H5" & vbLf & "$0$1&H4"

Any suggestions?




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Combine data in cells

Do you mean you want it on two lines?

With ActiveCell
.Formula = "=$n$1&H5"
.Offset(1,0).Formula = "$0$1&H4"
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"xgirl" wrote in message
...
Bob, Thank you for your help. However, the formula does not enter a

"line
feed" to pull down to the next line. It appears as wrapped text:

1)Incorrect maturity date on TIL2)Incorrect
maturity date on Note

I've also tried chr(13) in place of chr(10) but I get a runtime error when

I
use that.

I have the 1) in cell n1 the 2) in cell o1 and text in cells H4 and H5. I
want it to appear as:

1)Incorrect maturity date on TIL
2)Incorrect maturity date on Note

all in the same cell.

Thanks in advance.

"Bob Phillips" wrote:

With ActiveCell
.Formula = "=R1C14&R[" & 5 - .Row & "]C[" & 8 - .Column & "]&" &

_
Chr(10) & "R1C15&R[" & 4 - .Row & "]C[" & 8 -

..Column &
"]"
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"xgirl" wrote in message
...
Hi, I'm trying to write a macro that will combine the contents of 2

cells
in
to one with a line feed between each.

I tried to use vblf or chr(10) but it doesn't work.

ActiveCell.Formula = "=$n$1&H5" & vbLf & "$0$1&H4"

Any suggestions?






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Combine data in cells

I don't believe you can get a linefeed within a cell. wrapped text is about
the best you will get.

"xgirl" wrote:

Bob, Thank you for your help. However, the formula does not enter a "line
feed" to pull down to the next line. It appears as wrapped text:

1)Incorrect maturity date on TIL2)Incorrect
maturity date on Note

I've also tried chr(13) in place of chr(10) but I get a runtime error when I
use that.

I have the 1) in cell n1 the 2) in cell o1 and text in cells H4 and H5. I
want it to appear as:

1)Incorrect maturity date on TIL
2)Incorrect maturity date on Note

all in the same cell.

Thanks in advance.

"Bob Phillips" wrote:

With ActiveCell
.Formula = "=R1C14&R[" & 5 - .Row & "]C[" & 8 - .Column & "]&" & _
Chr(10) & "R1C15&R[" & 4 - .Row & "]C[" & 8 - .Column &
"]"
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"xgirl" wrote in message
...
Hi, I'm trying to write a macro that will combine the contents of 2 cells

in
to one with a line feed between each.

I tried to use vblf or chr(10) but it doesn't work.

ActiveCell.Formula = "=$n$1&H5" & vbLf & "$0$1&H4"

Any suggestions?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Combine data in cells

You can use Alt + Enter to insert a manual line break, but I am not sure how
that would be coded in VB unless it would be SendKeys.

"xgirl" wrote:

Hi, I'm trying to write a macro that will combine the contents of 2 cells in
to one with a line feed between each.

I tried to use vblf or chr(10) but it doesn't work.

ActiveCell.Formula = "=$n$1&H5" & vbLf & "$0$1&H4"

Any suggestions?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Combine data in cells

You have to use wrap text, but make the column wide enough so it doesn't
wrap before the char(10)
Sub ABC()
With ActiveCell
.EntireColumn.ColumnWidth = "100"
.Formula = "=N1&H4&char(10)&O1&H4"
.WrapText = True
.EntireColumn.AutoFit
End With
End Sub

worked for me.

--
regards,
Tom Ogilvy



"xgirl" wrote in message
...
Bob, Thank you for your help. However, the formula does not enter a
"line
feed" to pull down to the next line. It appears as wrapped text:

1)Incorrect maturity date on TIL2)Incorrect
maturity date on Note

I've also tried chr(13) in place of chr(10) but I get a runtime error when
I
use that.

I have the 1) in cell n1 the 2) in cell o1 and text in cells H4 and H5. I
want it to appear as:

1)Incorrect maturity date on TIL
2)Incorrect maturity date on Note

all in the same cell.

Thanks in advance.

"Bob Phillips" wrote:

With ActiveCell
.Formula = "=R1C14&R[" & 5 - .Row & "]C[" & 8 - .Column & "]&" &
_
Chr(10) & "R1C15&R[" & 4 - .Row & "]C[" & 8 - .Column
&
"]"
End With


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"xgirl" wrote in message
...
Hi, I'm trying to write a macro that will combine the contents of 2
cells

in
to one with a line feed between each.

I tried to use vblf or chr(10) but it doesn't work.

ActiveCell.Formula = "=$n$1&H5" & vbLf & "$0$1&H4"

Any suggestions?






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Combine data in cells

char(10) is same as Alt + Enter


Gord Dibben MS Excel MVP

On Wed, 4 Oct 2006 17:00:03 -0700, JLGWhiz
wrote:

You can use Alt + Enter to insert a manual line break, but I am not sure how
that would be coded in VB unless it would be SendKeys.

"xgirl" wrote:

Hi, I'm trying to write a macro that will combine the contents of 2 cells in
to one with a line feed between each.

I tried to use vblf or chr(10) but it doesn't work.

ActiveCell.Formula = "=$n$1&H5" & vbLf & "$0$1&H4"

Any suggestions?


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
combine data in two cells into a third cell ordnance1 Excel Worksheet Functions 3 September 25th 08 07:49 AM
Combine cells with the same reference and combine quantities brandon Excel Discussion (Misc queries) 2 September 17th 08 05:44 PM
Combine data that spans two rows, preserving cells? Bmuse Excel Discussion (Misc queries) 1 August 30th 07 03:14 AM
Combine text data from 2 cells Brad Excel Discussion (Misc queries) 3 May 15th 06 09:52 PM
How to combine 2 cells' data into 1 cell? [email protected] Charts and Charting in Excel 1 October 12th 05 02:54 AM


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"