+ Reply to Thread
Results 1 to 4 of 4

Indenting Text within a cell using VBA

  1. #1
    Registered User
    Join Date
    07-13-2017
    Location
    Puyallup, WA
    MS-Off Ver
    Excel for Mac (latest version)
    Posts
    26

    Indenting Text within a cell using VBA

    If I have 3 cells (A1,A2, and A3), and I display text in each, such as:
    A1: “Less then 1 .............. Ok”
    A2:”1 to 5 ........................Good”
    A3:” 6 to 10 .....................Great”

    How do I get the three words on the right (Ok, Good,and Great) to
    always be lined up vertically? I can use the space bar, and with trial
    and error, get them lined up, but if I run the vba code on a different
    PC with a different resolution, the words will be staggered.

    So how do I use a consistent indentation for the words in the right?

    I hope this makes sense.
    Last edited by tony333; 03-27-2019 at 01:24 AM.

  2. #2
    Registered User
    Join Date
    07-13-2017
    Location
    Puyallup, WA
    MS-Off Ver
    Excel for Mac (latest version)
    Posts
    26
    For cell A1, I tried using something like the following g
    to indent the word OK to the right by 5 spaces but I
    get a compiler error. Maybe it’s just my syntax.

    With Range (“A1”).Select
    ActiveCell.FormulaR1C1 = “Less then 1”
    Active.InsertIndent 5
    ActiveCell.FormulaR1C1 = “1”
    End With

    I realize I could use adjacent cells like B1 to capture
    my right hand word, and it would line up, but for my
    Application, I cannot use the B column cells.

    Help?!?
    Last edited by tony333; 03-27-2019 at 11:41 AM.

  3. #3
    Registered User
    Join Date
    07-13-2017
    Location
    Puyallup, WA
    MS-Off Ver
    Excel for Mac (latest version)
    Posts
    26
    Note: I also tried to use the Space() function, but that
    just does the same thing as hitting the space key multiple times.

    I need a way to force some text on the left-most side of a given cell,
    and then able to force other text in the right-most side of the same cell.

    It’s probably not possible.

  4. #4
    Registered User
    Join Date
    07-13-2017
    Location
    Puyallup, WA
    MS-Off Ver
    Excel for Mac (latest version)
    Posts
    26

    Re: Indenting Text within a cell using VBA

    Ah never mind! I figured it out myself, using the Justify
    Distributed command. In combination with some other stuff.

    Thanks for your help.

    Oh wait... I never got any help! lol

    😉

+ 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. Tabbing/Indenting within a cell
    By DianeMcP in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 07-29-2020, 01:24 PM
  2. [SOLVED] Optimize Code for indenting cell-content
    By JonasBig2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-13-2018, 07:01 AM
  3. Not Indenting Correctly
    By game001 in forum Word Formatting & General
    Replies: 1
    Last Post: 09-27-2016, 09:32 AM
  4. [SOLVED] Indenting cells with VBA where value in another cell matches criteria
    By barefaced66 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-19-2015, 10:46 AM
  5. indenting bullets at the end
    By amartino44 in forum PowerPoint Formatting & General
    Replies: 0
    Last Post: 12-02-2013, 06:11 PM
  6. help with indenting paragraph
    By wordup in forum Word Formatting & General
    Replies: 1
    Last Post: 11-21-2011, 09:53 AM
  7. Indenting wrapped text
    By j-dawg in forum Excel General
    Replies: 2
    Last Post: 06-13-2008, 02:54 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