+ Reply to Thread
Results 1 to 5 of 5

Formatting by matching columns A and B

Hybrid View

  1. #1
    Registered User
    Join Date
    10-10-2010
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Smile Formatting by matching columns A and B

    I am trying to format my data by state. I have listed in column A all the states i need, but the data I have each month do not always have all the states. The format of my data is:

    Column A (list of states) Column B (state in that month) Column C (#) Column D ($)

    So I wish to format by looking up the states listed in column B and comparing the the complete list of states in Column A, inserting a blank row if a state is missing for that month. Is there anyway to format this quickly in excel?
    Attached Files Attached Files
    Last edited by yunc1008; 10-10-2010 at 07:54 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Formatting by matching columns A and B

    I would recommend the VLOOKUP function (see Excel help for details).

    If you need the row to appear blank instead of getting a #N/A, you can nest this inside an IF function.

    E.g.

    =IF(ISNA(VLOOKUP(L3,B:D,1,0)),"",VLOOKUP(L3,B:D,1,0))

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Formatting by matching columns A and B

    You could insert two blank rows above your data, and then move your totals to the top like so:

          A ------B------- --C-- ------D------- ------E------- --F-- ------G------- ------H------- --I-- ------J-------
      1     All states: 40 14000 $22,602,175.18 All states: 36 18524 $23,655,493.91 All states: 44 30588 $53,859,016.73
      2                                                                                                                
      3     JAN                                 FEB                                 MAR                                
      4         State      Count     Amount         State      Count     Amount         State      Count     Amount
    Then select A4, B4, E4, & H4, and enter Keys in the Names box, left of the formula bar.

    Then unzip the attachment to someplace convenient, open the VBE, and drag xlAlignKeys.bas to the VBA project for the workbook.

    Then do Alt+F8, run AlignKeys to see this result, in part:

           A- ------B------- ---C--- ------D------- ------E------- ---F--- ------G------- ------H------- ---I--- ------J-------
       1      All states: 40   14000 $22,602,175.18 All states: 36   18524 $23,655,493.91 All states: 44   30588 $53,859,016.73
       2                                                                                                                       
       3      JAN                                   FEB                                   MAR                                  
       4          State       Count      Amount         State       Count      Amount         State       Count      Amount    
       5   AK AK             0000007     $11,453.89                                       AK             0000001         $96.71
       6   AL AL             0000003        $476.00                                       AL             0000001         $49.37
       7   AR                                                                             AR             0000006     $11,584.22
       8   AZ AZ             0000051     $53,496.58 AZ             0000028     $37,848.21 AZ             0000038     $76,667.52
       9   CA CA             0000054    $182,717.72 CA             0000085    $174,610.60 CA             0028107 $50,842,701.92
      10   CO CO             0000015     $13,368.82 CO             0008812  $9,776,433.72 CO             0000008     $18,399.11
      11   CT CT             0000198    $544,609.99 CT             0000019     $45,918.62 CT             0000055    $116,012.98
      12   DC                                                                             DC             0000017     $17,567.92
      13   DE DE             0000002      $2,728.55                                       DE             0000001        $322.56
      14   FL FL             0000010     $20,335.67 FL             0000048    $336,449.01 FL             0000046    $362,724.20
    Attached Files Attached Files
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,352

    Re: Formatting by matching columns A and B

    Hi ync1008,

    You have a perfect Pivot Table problem. The problem lies with having your data as you do. See the attached. I moved your data to Sheet2 and made it a table. Then used Pivot Tables to show exactly what you want.

    I hope this helps.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    10-10-2010
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Formatting by matching columns A and B

    Thank you all for your quick responses! This definitely saves me a lot of time trying to figure and sort data by myself =]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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