Reduce number of cells in Excel

后端 未结 3 1142
礼貌的吻别
礼貌的吻别 2021-01-22 23:49

I have a spreadsheet managing a list of groups in time slots. Imagine the below are cells:

0830-0845, Bob Hoskins, Jack Table, Phil Cup
0845-0900, Bob Hoskins, J         


        
相关标签:
3条回答
  • 2021-01-22 23:52

    Assuming your data starts in A2. Parse your input as Fixed Width to isolate the - and the first ,. Select Text for the first and third columns. Format the sheet as General. In D2 put:

    =IF(E1<>E2,"S",IF(E2<>E3,"F",""))  
    

    and copy down to suit.

    Copy ColumnD, Paste Special, Values over the top and delete rows with blanks in Column D. In B2 put:

    =IF(AND(D2="S",D3="F"),A2&"-"&C3,IF(D2="S",A2&"-"&C2,""))  
    

    and copy down to suit.

    Copy ColumnB, Paste Special, Values over the top and delete rows with blanks in Column B. In A2 put =B2&", "&E2 and copy down to suit. Copy ColumnA, Paste Special, Values over the top.

    Delete all but ColumnA.

    0 讨论(0)
  • 2021-01-23 00:10

    Partial solution that is fairly easy to maintain using Pivot tables:

    1. Get start time column:
      Add new column with formula: =VALUE(MID(RC[-4],1,4))
      Where RC[-4] is your original time range.

    2. Get end time column:
      Add new column with formula: =VALUE(MID(RC[-5],6,10))
      Where RC[-5] is your original time range.

    3. Concatenated names column:
      =CONCATENATE(RC[-5],RC[-4],RC[-3])
      Where RC[-5], RC[-4], RC[-3] are the cells with the name values.
      This is for grouping in Pivot Table.
      You should get something like this: New extended table
      Note headers are important!

    4. Insert a pivot table with your new extended table into a new worksheet:
      Set row labels to name concatenation column.
      Add start time column as value, with value field setting as min Add end time column as value, with value field setting as max
      Set the number format of min of start and max of end as '0000' so it displays time correctly Pivot table settings

    In terms of maintainability:

    • Set a dynamic source range for your Pivot table (fairly easy to do).
    • Update your extended columns by dragging formula or using hotkeys: ctrl+, ctrl+d to extend instead.
    • Write a very simple macro to extend/update the extended columns for you.

    Simplifications/Assumptions:

    • Ordering of names is significant i.e. do not treat collection of names as a set

    With excel, my advice is always to leverage existing tools as much as possible rather than use overly complicated cell formulas which can be hard to debug and possibly less efficient.

    Let me know if this output is useful enough otherwise I'll see what else can be done.

    0 讨论(0)
  • 2021-01-23 00:13

    I performed these steps as per Excel 2010, but this should work for other versions as well (with some minor changes).

    Steps:

    a) Select all data cells b) Goto Data --> Data Tools --> Remove Duplicates c) Seems that there are 4 columns in your data file, so in the popup you'll see 4 columns (say Column A, Column B, Column C, and Column D). Check all columns except Column A (i.e. where your timestamps exist). Press OK.

    Note: In this solution, the first timestamp (and not the range) will show up for each unique line e.g.

    0830-0845, Bob Hoskins, Jack Table, Phil Cup
    0945-1000, Jane Dunnit, Henry Badass    
    1030-1045, Terry Turbo      
    1100-1115, Simon Car, Maggie Blah, Jack Paper
    
    0 讨论(0)
提交回复
热议问题