+ Reply to Thread
Results 1 to 9 of 9

Check the particular values of several column of all rows

  1. #1
    Registered User
    Join Date
    03-14-2014
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Check the particular values of several column of all rows

    Hi, i'm a newbie to Excel VBA

    Currently, I need to create a macro that

    1. Check the values in several columns of the rows to find the rows with the same values
    2. Delete the first one and delete the rest
    3. add a specific number to the last column basing on the number of rows deleted

    For example I have

    Row 1 Car Long Red Apple Orange England 1

    Row 2 Car Short Blue Pear Melon China 1

    Row 3 Car Long Red Grape Berry England 1

    Row 4 Car Square Green Mango Kiwi England 1

    So when I run the macro, it will check the values of Column 2,Column 3, Column 4 and Column 7, after that it will delete the rows with similar values and then add a value to the 8th column based on the number of rows deleted.

    Which will look like this

    Row 1 Car Long Red Apple Orange England 2

    Row 2 Car Short Blue Pear Melon China 1

    Row 3 Car Square Green Mango Kiwi England 1


    Is it possible to do this?
    Thank you for any response :D

  2. #2
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Check the particular values of several column of all rows

    Hi mapleaes,

    Yes, it's probably possible but it would help if you post a file with a before & after data example.

    Thanks
    Remember you are unique, like everyone else

  3. #3
    Registered User
    Join Date
    03-14-2014
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Check the particular values of several column of all rows

    Hi, Sorry for not replying, the net is down for the whole weekend.

    I have attached the an excel file with the information you asked, hope it helps.

    And thanks for replying! :D
    Attached Files Attached Files

  4. #4
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Check the particular values of several column of all rows

    Thanks mapleaes,

    I think I've got you now, if the Columns 'Dealer', 'Model', 'State' and 'Color' are the same, keep only 1 record but increase the count by the number of records deleted.

    I think what you're trying to achieve is to summarise the data by the 4 Columns but keep a total count the same as the original.

    Also, it doesn't matter if the 'Chassis' & 'Engine' values are deleted.

    Is that right?

  5. #5
    Registered User
    Join Date
    03-14-2014
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Check the particular values of several column of all rows

    Yes it is :D

  6. #6
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Check the particular values of several column of all rows

    Hi mapleaes,

    I think you can use a Pivot Table for this & make the sort easier.

    See the attached file.

    I have created a Pivot Table (excluding the Chassis & Engine fields) that is the same as your end results table.

    Let me know what you think.

    Cheers

  7. #7
    Registered User
    Join Date
    03-14-2014
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Check the particular values of several column of all rows

    Thank you very much! XD
    I just step into the world of Excel VBA and all my manager ever rams about is macro, so i thought that macro is the only viable option
    :P

    Thanks for telling me about the pivot table :D

    Oh yeah, by any chance could you tell me how did you design your pivot table? I tried making one myself but the result looks more like a tree view than a table.

    Thanks again :D

  8. #8
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,071

    Re: Check the particular values of several column of all rows

    A Macro could do it but would be more complex than a Pivot Table (PT).

    To change the tree view of your PT, right click on any cell inside it & select 'Pivot Table Options' >> click on the 'Display' Tab & select 'Classic PivotTable layout' & click OK.

    You can then select the fields that have 'Total' after the field name & right click to go to 'Field Settings' & select 'None' to remove this Row.

    Try these steps & see how you go, let me know if you get stuck.

    Cheers

  9. #9
    Registered User
    Join Date
    03-14-2014
    Location
    Malaysia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Check the particular values of several column of all rows

    Thanks very much, I was able to done it with ease :D

    Again thank you very much for helping me on my issue, you've been a great help

+ 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. [SOLVED] Check the same values and delete if same, sort rows in sentence
    By Odeen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-05-2013, 04:02 AM
  2. Replies: 5
    Last Post: 11-12-2012, 08:38 PM
  3. Replies: 7
    Last Post: 10-01-2012, 09:20 AM
  4. Need to Check to see if all values are met in a column
    By 1benji in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-03-2012, 03:07 AM
  5. Script to check for duplicates in one column then alter adjacent column values
    By SebN in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-29-2010, 12:23 PM

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