+ Reply to Thread
Results 1 to 23 of 23

Align two word in the same cell in different way

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Align two word in the same cell in different way

    Hello everybody
    I have data in Column H in range("H2:H" & LastRow)
    Each cell has two words ...one in Arabic and the other in English
    I need a macot that enables me to aligh the first word in Arabic to the right and the second word in English to the left
    Thanks advanced for help
    Attached Files Attached Files
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Align two word in the same cell in different way

    Maybe :

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Align two word in the same cell in different way

    Thank you very much Mr. Karedog for this wonderful code
    The results are good but the results are not the expected ..
    I need to align the Arabic word to the right in the first line and the English word to be aligned to the left the second line
    Thanks a lot

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Align two word in the same cell in different way

    So the Arabic part is reversed ? Please try this modified code :

    Please Login or Register  to view this content.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Align two word in the same cell in different way

    ..or a formula solution - which could also be added by a macro if that's vital. Assumes a total length of 30 characters. Adjust as necessary


    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Align two word in the same cell in different way

    Thanks a lot for helping me in this issue
    I have attached the desired results

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Align two word in the same cell in different way

    Clearly we have a different interpretation of the words align right & left. In Excel terminology 'aligning' is associated with the positioning of values to left edge, middle or right edge of a cell.

    It seems your requirement is to align in the centre with three characters separating the two words. It always pays to be precise or we waste our time.

  8. #8
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Align two word in the same cell in different way

    I'm sorry Mr. Richard for not being precise
    I meant to make the Arabic word to the right in the first line and the English word to the left in the second line (I didn't mean align literally) .. and try to forgive me as English in not my native language
    Best Regards

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Align two word in the same cell in different way

    ...indeed and understood.
    It was enough to simply request that the bottom word should precede the top word on the same line in the cell.

  10. #10
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Align two word in the same cell in different way

    I still don't understand the requirement. I don't see any changes in the second uploaded file compared to first one (I don't see the expected result).

    Here I put 2 codes, maybe one of them is what you need.

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Align two word in the same cell in different way

    Thanks a lot Mr. Karedog for all these great solutions ...
    I will work on last code Test3 .. although it is not the desired result but it is more accurate than any other solution
    I liked it a lot
    Thank you very much for awesome and genius solution
    Best Regards

  12. #12
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Align two word in the same cell in different way

    You are welcome. If this is not the desired result, could you take the screenshot (instead of workbook) the result if you do it manually ?
    Because when I open the file on post #6, there is only one sheet with content is exactly same as first post (beside the command button and the added macro).

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Align two word in the same cell in different way

    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Align two word in the same cell in different way

    Thank you very much Mr. Jindon
    Here's a screen shot for the desired result
    Untitled.png

    But I need the two words in once cell one to the right and the other to left

    Or another approach if this will be complicated to get the desired results (every word in single cell : cell to the right and the next cell to the left as in the screen shot) but th results would be after the last cell of column H (I mean in the same cell)

    Thank you everybody for help

  15. #15
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Align two word in the same cell in different way

    Doesn't my "Sub Test2()" do exactly what you mean ? Just widen column H (for example set column H width to 40) before run Sub Test2().

    Link to animated gif :
    http://s7.postimg.org/sry0zmlu3/Align_Right_Left.gif
    Last edited by karedog; 02-26-2016 at 01:20 AM. Reason: Add link

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Align two word in the same cell in different way

    Please Login or Register  to view this content.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Align two word in the same cell in different way

    For the safety, data like

    Father's Job
    وظيفة الأب"

    Arabic comes after
    Please Login or Register  to view this content.

  18. #18
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Align two word in the same cell in different way

    Thank you very very much for these wonderful solutions
    In fact I liked all these solutions ..
    @Mr. karedog the sub Test2 works very very well but I had to put a line of code to make the column width =40 at the end of the code to get the best results ..
    It is working but the column width becomes too large in that case and I noticed extra line between the two words
    Is it possible to adjust that a little to get rid of the extra line between...and make the column width less

    @Mr. Jindon
    Your last code in Post #17 is awesome ..
    Just two points I need if possible :first to get the results starting at H7 which is the first balnk cell after last cell
    Second to get the Arabic words first (if possible)

    Thank you very much for supporting this issue..I am very grateful for both of you
    Please Login or Register  to view this content.

  19. #19
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Align two word in the same cell in different way

    Quote Originally Posted by YasserKhalil View Post
    @Mr. karedog the sub Test2 works very very well but I had to put a line of code to make the column width =40 at the end of the code to get the best results ..
    It is working but the column width becomes too large in that case and I noticed extra line between the two words
    Is it possible to adjust that a little to get rid of the extra line between...and make the column width less
    In fact, setting column width must be done before you run sub Test2, and it is not problem at all if you don't adjust the column width.
    The choose of column width is personal taste, that's why I don't include the code to set it.
    There is no extra line when I run the code in my PC (tested on Excel 2003 and 2007), and there is no code to do so in sub Test2, so if there is an extra line on your PC, this is something strange, maybe caused by your Mid Eastern Office version ?
    The result of my code on my PC can be looked at the link on post #15.

  20. #20
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Align two word in the same cell in different way

    Thanks a lot for explaining the difference of version may be the casue .. and the evidence is that I found a way without using macro to do the task
    By selecting range("H2:H6") and right click >> Format cells >> Alignment tab >> In Horizontal section select "Justify" ..it is working to some extent but it is vice versa :: the Arabic appears to the left edge (not the right edge) and the English word appears to the right edge(not the left edge)

    Generally .. Can you help me in the other approach which is to split both words to single cells : the Arabic word in a cell and the English word in the next cell and so on ... and align Arabic to right edge and Englsih to the left

    Here's the last desired results that I wish in the same column ....
    Untitled.png

  21. #21
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Align two word in the same cell in different way

    Please Login or Register  to view this content.

  22. #22
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Align two word in the same cell in different way

    Done, by jindon

  23. #23
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Align two word in the same cell in different way

    Thank you very much Mr. Jindon for this perfect solution. It is awesome and fascinating
    Thanks a lot Mr. Karedog for all the great and wonderful solutions..

    I am very happy with your help ..you ar GENIUS people
    Best Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to Align Bold Word Left or Right
    By Roco in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-17-2015, 07:07 PM
  2. Paste strings of multiple lengths into word and right-align last character ???
    By frankienap in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2014, 03:54 PM
  3. Align Left and Right in Same Cell
    By snapfade in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-25-2014, 04:08 PM
  4. Formatting: Vertically Align 2nd word in cell
    By wkhenry in forum Excel General
    Replies: 3
    Last Post: 08-09-2011, 03:01 PM
  5. [SOLVED] how can I align excel page numbers with Word
    By Kenneth in forum Excel General
    Replies: 1
    Last Post: 06-15-2006, 07:35 PM
  6. Left align '$' and right align numbers?
    By skeetley in forum Excel General
    Replies: 1
    Last Post: 10-21-2005, 03:12 AM
  7. [SOLVED] What is short-Cut forleft align and Right align?
    By Sandy in forum Excel General
    Replies: 1
    Last Post: 02-24-2005, 09:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1