+ Reply to Thread
Results 1 to 2 of 2

Custom Format to Align Text in a Cell

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    02-07-2013
    Location
    Philippines
    MS-Off Ver
    Excel Online; 365
    Posts
    633

    Custom Format to Align Text in a Cell

    Hi Team,

    Are there any custom formats i could use to center align a particular text in a cell if it is chosen in a dropdown validation (example: N/A)?

    I would like "N/A" to be aligned in the center and all other choices aligned to the left.


    Thanks,

    bhenlee

  2. #2
    Valued Forum Contributor
    Join Date
    09-25-2011
    Location
    Eastbourne, England
    MS-Off Ver
    Excel 2010
    Posts
    1,089

    Re: Custom Format to Align Text in a Cell

    Hi bhenlee

    One way would be to use "worksheet change" routine

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Intersect(Target, Range("c1:c1000 ")) Is Nothing Or Target.Cells.Count > 1 Then Exit Sub
    'Change the cell reference above to what you need
        If Target <> "N/A" Then Exit Sub
        Application.EnableEvents = False
        Target.HorizontalAlignment = xlCenter
        Application.EnableEvents = True
    End Sub
    To enter this code copy it, right click on the sheet tab and go to "View code". Paste the above. Any "N/A" entry in c1:c1000 (amend as you need) will be centre justified.

    Let me know if this works for you

    Regards
    Alastair

+ 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. Combobox Left Align Text that's too long to fit into cell
    By tigerlilly4321 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2013, 12:08 AM
  2. [SOLVED] Custom Cell Format - Number ending with text string
    By BeautyBlues in forum Excel General
    Replies: 4
    Last Post: 06-20-2013, 07:53 AM
  3. [SOLVED] Format align text in column when export to excel with VBA
    By Cuong Pham in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2013, 12:11 AM
  4. Align text in cell acording to the text it contains
    By AlecsV in forum Excel General
    Replies: 1
    Last Post: 08-25-2012, 11:50 AM
  5. [SOLVED] Custom format a text cell with square brackets: [ ] ?
    By StargateFan in forum Excel General
    Replies: 2
    Last Post: 02-06-2005, 12:06 PM

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