PDA

View Full Version : Can we write both in left and right alignment in same cell?



jungix
06-23-2006, 08:15 AM
Hi,

I have some cells in which I write long texts at first, and the width of this column is set so as to be just one A4 page.


Below this, I want to write 2 things separately, so I used 2 columns, but then the second one is not on the same page when I print.
Can I write the second thing at the right of the big cell, even if there is something in the left? (Both are short enough and they will never collide).
Or can I separate a cell in 2, where I would put one of each? The problem is that I can't do that manually because the row index when the second part starts may vary, and I want that the next time I run the program it is again one single row (because the first list could be longer)

lucas
06-23-2006, 08:27 AM
You might try using 2 columns all the way down and set your print area to the 2 columns. In the first instead of merging the 2 columns you can format them to center across selection which has the same effect(appearance) as merging the cells but there is no merge...the two cells are still in place.

jungix
06-23-2006, 09:59 AM
And how am I supposed to do this?

I tried to copy like that:

Range(Cells(k, 2), Cells(k, 3)).Select
ActiveSheet.Paste

But it doesn't work. It copys the text in each one of the cells (I would need it only once but all over the 2 cells.

lucas
06-23-2006, 10:09 AM
I just recorded the steps with the recorder to get this:
Sub Macro1()
Range("E5").Select
ActiveCell.FormulaR1C1 = "This is a test"
Range("E5:F5").Select
With Selection
.HorizontalAlignment = xlCenterAcrossSelection
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("G18").Select
End Sub

jungix
06-23-2006, 11:15 AM
Thanks, but I was more looking for something like
.HorizontalAlignment = xlLeftAcrossSelection

Doesn't it exist?

mdmackillop
06-23-2006, 01:26 PM
Hi Jungix,
I made up this KB item http://vbaexpress.com/kb/getarticle.php?kb_id=481 to split long text into separate rows, which may suit your purpose. Try using 0.46 as the ratio, rather than the suggested 0.23, and adjust the column widths to suit.
Regards
MD