+ Reply to Thread
Results 1 to 13 of 13

Formatting issue for an itemized list

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-29-2010
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    111

    Formatting issue for an itemized list

    While testing out the generously donated coding for a formatting issue that converts a .html file into a usuable Excel file, I ran into an unexpected issue.

    I have instances where multiple items are sharing these same item number (yes this does not make sense to me either).

    The coding formats data from a 13 row structure, but in instances where there is an itemized list for one number the data is only 3 rows long.

    If anyone could help in creating coding that can expand those 3 row data sets to the 13 rows neeed for the original coding, by drawing from the last normal 13 row data set you would be making life far more enjoyable for myself and a lot of other people.

    I have attached the test file. It includes the original structure breakdown (explained from columns A-D, and the coding to address my original formatting issues. In addition I added explanations on what I am trying to have accomplished with a full breakdown in Columns E-J (rows 160 and below). Please let me know if my attempt at an explanation is still unclear and thanks in advance for any support that you can provide.


    Thanks again,

    D
    Attached Files Attached Files
    Last edited by Biased Historian; 12-17-2010 at 11:38 AM. Reason: typos

  2. #2
    Forum Contributor
    Join Date
    06-29-2010
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Formatting issue for an itemized list

    Please advise if the explanation provided on what I am looking to accomplish in the test workbook is not clear enough.

    Thanks,

    D

  3. #3
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Formatting issue for an itemized list

    Biased Historian,

    Can you post an updated workbook, with Sheet1 containg the raw data in column A only.

    And, Sheet2 would contain just Sheet1's data in the correct format.

    And, finally, can we have more samples of the data in Sheet1 column A.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  4. #4
    Forum Contributor
    Join Date
    06-29-2010
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Formatting issue for an itemized list

    Attached the requested workbook. Sheet 1 contains the original information that the code provided formats. Sheet 2 shows the results of executing the code and shows what the format looks like. Sheet 3 shows the itemized list causing the issue. It is added into the original information.

    The 1st workbook attached attempts to explain where the cells need to end up so that it all looks like sheet 2. This becomes complicated (at least in my mind) because it not only needs to reorder the cells, but draw from previous cells to fill in the missing pieces.

    Here is the code provided to me, which works off of reassembling 13 cells of information per item. The additional code would need to address the issue of items that only contain 3 cells of information (because they are itemized under one number vs. one item per number) , but need the 10 other cells to draw from in order to reassemble like every other row of items.

    I know it may sound a bit confusing, thus my cell by cell breakdown by colored backgrounds in the 1st workbook.

    The code-

    Option Explicit
    
    Sub ReformatData()
    Dim CaseFND As Range
    Dim LR As Long, Rw As Long
    Dim NR As Long
        
        Application.ScreenUpdating = False
        On Error Resume Next
        
        Set CaseFND = Range("A:A").Find("Case:", LookIn:=xlValues, LookAt:=xlPart)
        If CaseFND Is Nothing Then Exit Sub
    
        Range("A1", CaseFND.Offset(-1)).Delete xlShiftUp
        LR = Range("A" & Rows.Count).End(xlUp).Row
        
        For Rw = LR To 1 Step -1
            If Range("A" & Rw).Font.Bold = False Then
                Range("A" & Rw + 1, "A" & LR).Delete xlShiftUp
                Exit For
            End If
        Next Rw
    
        LR = Range("A" & Rows.Count).End(xlUp).Row
        NR = 1
        For Rw = 2 To LR Step 12
            Range("A" & Rw).Resize(12).Copy
            Range("B" & NR).PasteSpecial xlPasteAll, Transpose:=True
            NR = NR + 1
        Next Rw
        
        Range("A2:A" & LR).ClearContents
        Columns.AutoFit
        Application.ScreenUpdating = True
    End Sub

  5. #5
    Forum Contributor
    Join Date
    06-29-2010
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Formatting issue for an itemized list

    Attachments can't seem to be uploaded right now so i will have to wait-

    d

  6. #6
    Forum Contributor
    Join Date
    06-29-2010
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Formatting issue for an itemized list

    Weird...would not let me upload the excel file, had to zip it first. First time that has happened.

    Anywho here is the file, broken down on each sheet as requested. Hopefully between this working workbook and the "test2" workbook that breaks down the cell formatting needed, it is now clearer on what I am trying to achieve.

    Thanks for all of your help,

    Dave
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Formatting issue for an itemized list

    Biased Historian,

    With your raw data in Sheet1, per you latest workbook, try the following macro.


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    
    Option Explicit
    Sub ReorgData()
    ' stanleydgromjr, 12/18/2010
    ' http://www.excelforum.com/excel-programming/757145-formatting-issue-for-an-itemized-list.html
    Dim w1 As Worksheet, wR As Worksheet
    Dim c As Range, Caddr As String
    Dim LR As Long, NR As Long, SR As Long, ER As Long, a As Long
    Application.ScreenUpdating = False
    Set w1 = Worksheets("Sheet1")
    If Not Evaluate("ISREF(Results!A1)") Then Worksheets.Add(After:=w1).Name = "Results"
    Set wR = Worksheets("Results")
    wR.UsedRange.Clear
    w1.Activate
    LR = w1.Cells(Rows.Count, 1).End(xlUp).Row
    With w1.Range("A1:A" & LR)
      Set c = .Find("CASE NO:*", LookIn:=xlValues, LookAt:=xlWhole)
      If Not c Is Nothing Then
        Caddr = c.Address
        Do
          SR = c.Row + 1
          NR = wR.Range("B" & Rows.Count).End(xlUp).Offset(1).Row
          wR.Range("A" & NR) = w1.Range("A" & SR - 1)
          For a = SR To SR + 200 Step 1
            If Cells(a, 1) = "VALUE:" Then
              ER = a - 3
              Exit For
            End If
          Next a
          For a = SR To ER Step 12
            wR.Range("B" & NR).Resize(, 12) = Application.Transpose(w1.Range("A" & a & ":A" & a + 11))
            NR = NR + 1
          Next a
          Set c = .FindNext(c)
        Loop While Not c Is Nothing And c.Address <> Caddr
      End If
    End With
    LR = wR.Cells(Rows.Count, 2).End(xlUp).Row
    wR.Range("D1:D" & LR).NumberFormat = "$#,##0.00_);($#,##0.00)"
    wR.Range("G1:J" & LR).NumberFormat = "m/d/yyyy"
    wR.UsedRange.Columns.AutoFit
    wR.Activate
    Application.ScreenUpdating = True
    End Sub

    Then run the ReorgData macro.

  8. #8
    Forum Contributor
    Join Date
    06-29-2010
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Formatting issue for an itemized list

    Thanks Stan,

    It worked great on the data until the itemized list, then the order jumped around a bit.

    I put together a new workbook that put everything together that I could mimic on sheet 1. I ran the latest code provided, then cut and pasted in the itemized list to show how it would look if the code were to execute it. I left the itemized list in sequence by the order in the report, for example 1 through 15. If the code could over write those order numbers with the shared property number, in this case 08-ABC-050560, that would work too.

    Please let me know if there is anything else I can do and I apologize that it appears that sheet 3 in the previous workbook turned out blank. That had the itemized information in it but I was having trouble uploading yesterday and something must have gone wrong during that process.

    As always thank you to all for everything,

    I also attached the structure, which can also be found in my first file in the thread-
    Attached Files Attached Files
    Last edited by Biased Historian; 12-19-2010 at 12:20 PM.

  9. #9
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Formatting issue for an itemized list

    Biased Historian,

    I am having a problem understanding the logic for the section in Sheet1, column A, beginning with CASE NO: 780005-99-0606 Carrots.

    Click on the New Post button, and just enter the text BUMP, then click on the Submit Reply button, and someone else will assist you.

  10. #10
    Forum Contributor
    Join Date
    06-29-2010
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Formatting issue for an itemized list

    Per Stan's advice I am selecting to BUMP this topic.

    First- thank you Stan for the help that you have provide don this.

    I am going to try and break this down as best I can.

    What I am attempting to do is convert a html report into an Excel file.

    Thus far I have been provided with two great solutions to a report that assigns one item number to an item. The coding takes information on each item and places it into one row per item,over several columns.

    The information to form each item row comes from 13 cells in column A.

    CASE NO: 020-10-08 A-1 Starting cell
    MUTTON 98 LARS 89 B-1
    N/A C-1
    $100.00 D-1
    N E-1
    03-abc-011122 F-1 (1 item number per item)
    1/29/2003 G-1
    7/29/2005 H-1
    5/29/2009 I-1
    5/29/2003 J-1
    N/A K-1
    2744 L-1
    N M-1 Ending Cell


    Where I ran into an unexpected problem is that on some reports a single item number is used for multiple items, called an itemized list.

    The reason the coding will not work in on an itemized list is because the information to form each row only comes from only 3 cells in column A.


    $30.00 D-2
    Lincoln Leg 3421 B-2
    1 F-2
    $69.00 D-3
    Tanner 98 LARS B-3
    2 F-3
    $640.00 D-3
    Banner 56 B-4
    3 F-4


    I am looking for coding that will identify and form a full 13 column single row for an itemized list item, using not only the 3 cells on the report (B, D, F), but also draw from the other 10 cells (A,C,E,G,H,I,J,K,L,M,N) of the last full 13 cell structure and repeat this process until reaching the end of the itemized list.

    If that coding works then the converted report will have the same format, whether the item has a single item number, or is one of multiple items in a list that share the same item number.

    Thank you for your patience and help, as this is not an easy thing to explain.

    Dave

  11. #11
    Forum Contributor
    Join Date
    06-29-2010
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    111

    Re: Formatting issue for an itemized list

    BUMP

    Still looking for any guidance or assistance on adding coding within the provided codes to address itemized lists.

    Thanks,

    D

+ 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