+ Reply to Thread
Results 1 to 16 of 16

Change the width of indent for a cell

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Change the width of indent for a cell

    Hi,
    I want to cut half of the indent width in a cell, so that leave a narrow space
    between the text and the column vertical line. One reason I want it narrower
    is to reduce the column width. I like to have a variable setting instead of half
    of the default indent width. Some time I do is to use two columns instead
    use of indent.

    Is that possible in setting, VBA?
    Last edited by Rocky2013; 09-12-2018 at 08:10 AM.

  2. #2
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Change the width of indent for a cell

    Quote Originally Posted by Rocky2013 View Post
    Hi,
    I want to cut half of the indent width in a cell, so that leave a narrow space
    between the text and the column vertical line. One reason I want it narrower
    is to reduce the column width. I like to have a variable setting instead of half
    of the default indent width. Some time I do is to use two columns instead
    use of indent.

    Is that possible in setting, VBA?

    try this on a separate sheet.
    hope this is what you needed.
    thanks

    place cursor on the preferred CELL then run the macro..
    check "Format Cell" - to see if indent is as entered.

    Sub Adjust_Cell_Indent()
        x = Val(InputBox("Enter number of indent"))
        adj_Cell_Indent (x)
    End Sub
    
    Sub adj_Cell_Indent(mInd As Long)
        With Selection
            .IndentLevel = mInd
        End With
    End Sub

  3. #3
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Change the width of indent for a cell

    Thanks for reply. This is not what I am looking.

    I enter "1" indent when prompt, the result is the same
    space as the "Increase Indent" pick from the toolbar.

    I check the default width of "Increase Indent", it holds three characters before
    the cell content. I need "1" character space, to separate the beginning of cell content and vertical
    column line. I want to apply the format to the entire column, and all columns that have the cell
    contents. I can apply default "Increase Indent" to entire column.

    I use these methods before but I want a better approach if I can change the width of indent.
    1. I hit a space bar, then type ..., I repeat these for every rows.
    2. Use two columns, the width of left column sets to "1", a vertical border line
    is drawn, then type text in right column. So that the text appears has a space
    for a clear look.

    Thanks

  4. #4
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Change the width of indent for a cell

    the codes I provided can make the necessary index adjustments for any cell selected - even for a range, an entire columns or sets of columns.
    all you have to do is select - for entire range, mouse click the top of the columns (where the letters are) then ran the macro; just select (highlight)
    wherever you want index changed then run the macro.
    if you want 1 space indent - just input 1 on the prompt.
    hope this helps....
    thanks

  5. #5
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Change the width of indent for a cell

    Hi,
    I did try the macro.
    I enter "1" for number of indent = same as "Increase Indent" from menu bar. one indent has 3 characters space.
    I want the space to be narrower to align the cell left border, I enter "0.5" for number of input. Text does not
    show any change in position.

    The code seems does not accept number below "1", or any decimal places. I enter "1.5", text space
    shows 2 indents.
    Instead using code for indent, how about code to insert a character space (one space bar) in a cell
    or range of cells, before the text. I think a character space visually appears better than without
    any space. I do not like the text is align left or right text against the vertical column line(s).

    Thanks

  6. #6
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Change the width of indent for a cell

    the simplest way of what you are saying is:
    press the space bar - then type in the text....
    no codes - no hassle..
    thanks

  7. #7
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Change the width of indent for a cell

    Quote Originally Posted by LFKim2018 View Post
    the simplest way of what you are saying is:
    press the space bar - then type in the text....
    no codes - no hassle..
    thanks
    My problem is I am creating a form for someones to use. I want to format the cells so that the spread sheets
    always looks consistence. The person enters may forget or does not care to have space. Another way I said before
    to create two columns, 1 character space column and a text column, I do not like that much.

    Thanks

    always has a character space to make the spread sheet

  8. #8
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Change the width of indent for a cell

    Quote Originally Posted by Rocky2013 View Post
    My problem is I am creating a form for someones to use. I want to format the cells so that the spread sheets
    always looks consistence. The person enters may forget or does not care to have space. Another way I said before
    to create two columns, 1 character space column and a text column, I do not like that much.

    Thanks

    always has a character space to make the spread sheet
    try this first in a separate sheet - do not test this directly on your work

    see image - self explanatory
    hope this helps
    thanks..

    format with comma.PNG

  9. #9
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Change the width of indent for a cell

    try below in a separate sheet - do not test it directly on your work

    maybe another way of achieving your goal.
    just input your text as usual - then run the macro to insert 1 space.
    hope this helps
    thanks..


    Sub Insert1SpacetoText()
        Application.ScreenUpdating = False
        On Error Resume Next
        Dim mcol As String
        mcol = InputBox("Enter Column to insert 1 space for text")
        check_col = Cells(1, mcol).Column
        If check_col <= 0 Then
            MsgBox "Column input error!", vbCritical
            Exit Sub
        End If
        Dim i As Long
        For i = 2 To Cells(Rows.Count, mcol).End(xlUp).Row
            Cells(i, mcol) = " " & Cells(i, mcol)
        Next i
        Application.ScreenUpdating = True
        On Error GoTo 0
    End Sub

  10. #10
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Change the width of indent for a cell

    Quote Originally Posted by LFKim2018 View Post
    try below in a separate sheet - do not test it directly on your work

    maybe another way of achieving your goal.
    just input your text as usual - then run the macro to insert 1 space.
    hope this helps
    thanks..


    Sub Insert1SpacetoText()
        Application.ScreenUpdating = False
        On Error Resume Next
        Dim mcol As String
        mcol = InputBox("Enter Column to insert 1 space for text")
        check_col = Cells(1, mcol).Column
        If check_col <= 0 Then
            MsgBox "Column input error!", vbCritical
            Exit Sub
        End If
        Dim i As Long
        For i = 2 To Cells(Rows.Count, mcol).End(xlUp).Row
            Cells(i, mcol) = " " & Cells(i, mcol)
        Next i
        Application.ScreenUpdating = True
        On Error GoTo 0
    End Sub
    Hi,
    Not working, Column input error! Is this code works the same way as the first code you provide.
    I need code to to insert a character space; is that possible?

    Thanks

  11. #11
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Change the width of indent for a cell

    at the prompt - did you enter the letter of the column?

  12. #12
    Registered User
    Join Date
    07-20-2018
    Location
    Quezon City, Philippines
    MS-Off Ver
    Excel 2013
    Posts
    84

    Re: Change the width of indent for a cell

    Quote Originally Posted by Rocky2013 View Post
    Hi,
    Not working, Column input error! Is this code works the same way as the first code you provide.
    I need code to to insert a character space; is that possible?

    Thanks
    attached is a sample for you to test (pls download the latest attachment - with added error checking)
    this can be applied if the text were already entered and you want to insert 1 space.
    hope this helps
    thanks..
    Attached Files Attached Files
    Last edited by LFKim2018; 09-06-2018 at 08:41 PM.

  13. #13
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Change the width of indent for a cell

    Quote Originally Posted by LFKim2018 View Post
    attached is a sample for you to test (pls download the latest attachment - with added error checking)
    this can be applied if the text were already entered and you want to insert 1 space.
    hope this helps
    thanks..
    The code works by selecting cell range or column > run the marco > at pop windows, Click OK (not enter any number or "," to avoid error pop-up
    > Click "," from the number menu > if the text is already, text automatically shows align left with a one-character space, number aligns right
    with one-character space.

    There are many columns will use one-character indent in different worksheets. It seems after I run marco to format the cells or columns.
    The marco and format retain even after I close and reopen the workbook. Maybe I do not need to run the marco and format the each time
    when workbook is opened.

    One more thing is I want an option to have align left or align right, can that be done?
    When I click align left on the number that is formatted with marco for align right, the number is locked.
    The number were disabled to use middle and align left. Do you I do another marco to change number alignment?

    Thanks

  14. #14
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Change the width of indent for a cell

    Hi,
    Also how about undo button to clear all format in the active worksheet that use this marco?

    Thanks again

  15. #15
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,343

    Re: Change the width of indent for a cell

    Indent values are whole numbers only, so no you can't set it to 0.5 for example.
    Everyone who confuses correlation and causation ends up dead.

+ 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. Change Cell Width/Height for certain range
    By lborja in forum Excel General
    Replies: 0
    Last Post: 02-09-2016, 05:35 PM
  2. Change Cylinder Height and Width from a cell value
    By korn.deuce in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-11-2013, 11:25 AM
  3. Indent move cell, 2 indent move 2 cells etc
    By jomuir in forum Excel General
    Replies: 3
    Last Post: 05-14-2012, 11:56 AM
  4. Change column width if cell changes
    By 2Excel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2011, 01:08 AM
  5. How to change cell width w/o effecting other rows
    By tqdinh22 in forum Excel General
    Replies: 1
    Last Post: 07-19-2006, 02:16 PM
  6. Change the width of a column by using a cell reference
    By None Specified in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-03-2006, 05:00 PM
  7. [SOLVED] How do I change the width of an individual cell?
    By Tabitha in forum Excel General
    Replies: 3
    Last Post: 08-28-2005, 02:05 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