+ Reply to Thread
Results 1 to 5 of 5

Indent multiple Columns based on Value in One Column

  1. #1
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Indent multiple Columns based on Value in One Column

    Hi all:
    Looking to format a BOM down-load (into Excel), so that the BOM levels are indented according to the level number.
    Levels are indicated in Column C. Columns to indent would be C thru F.
    Number of rows is undetermined.

    Setting up the code, I have the following - although so far mostly instructions without code.
    I hope the requirements are expressed clearly enough.

    Please Login or Register  to view this content.
    Last edited by BEEJAY; 04-15-2011 at 03:36 PM.

  2. #2
    Valued Forum Contributor jwright650's Avatar
    Join Date
    12-10-2010
    Location
    Va, USA
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    606

    Re: Indent multiple Columns based on Value in One Column

    BEEJAY,
    Do you have some sample data that you can post as an example of what the D/L looks like when you get it? A sample xls file with some sample data would be helpful.

    I believe you can use a Select Case type of loop to do your formatting for you.
    Once you select your range, you can use this to perform the indenting.
    Please Login or Register  to view this content.
    Life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
    John Wright

  3. #3
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Indent multiple Columns based on Value in One Column

    Hello jwright650

    I'm still very new to this forum, so I'm not yet comfortable with all the bells and whistles available. If I'm doing anything wrong, please let me know.

    I am trying to attach a sample file.
    The top section shows the down-loaded data.
    The 2nd section shows how I need it to look when indented.

    Thank-you
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Indent multiple Columns based on Value in One Column

    Try this:
    Sub SetIndent()
    Dim intLastRow, intIndent
    intLastRow = Range("A65536").End(xlUp).Row

    For Each c In Range("C2:F" & intLastRow)
    intIndent = ActiveSheet.Range("C" & c.Row).Value
    If intIndent > 0 Then
    Select Case intIndent
    Case 1
    intIndent = 2
    Case 2
    intIndent = 4
    Case 3
    intIndent = 6
    Case 4
    intIndent = 8
    Case 5
    intIndent = 10
    Case 6
    intIndent = 12
    End Select
    c.InsertIndent intIndent

    End If
    Next c
    End Sub
    Last edited by tlafferty; 04-13-2011 at 02:12 PM. Reason: needed to account for additional indent beyond specified value in cell.

  5. #5
    Registered User
    Join Date
    03-17-2011
    Location
    Guelph, Ontario, Canada
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Indent multiple Columns based on Value in One Column

    tlafferty:
    I used your initial submission and it appears to fit the bill.
    I will keep a close eye on it, to make sure I'm not overlooking something obvious.
    I saved the 'case' method with the other one, and will give it a try shortly.
    I expect it is 'more accurate', based on my initial criteria - it is also more flexible.

    Thanks for the prompt responses. As of noon today, this project is complete. I'm looking forward to some H.D. use of the macro starting Monday.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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