+ Reply to Thread
Results 1 to 5 of 5

VBA Macro to prevent unsorted duplicated row

  1. #1
    Registered User
    Join Date
    04-19-2016
    Location
    Bruxelles
    MS-Off Ver
    2010
    Posts
    2

    VBA Macro to prevent unsorted duplicated row

    Hi,
    I need a vba macro for my xlsx file.

    I have a file with header and 3 columns.
    The column "col1" could contain duplicated values.
    But the duplicates values have to be grouped together

    The following is OK

    col1 col2 col3
    4 xx xx
    4 xx xx
    2 xx xx
    3 xx xx
    3 xx xx


    The following is NOK

    col1 col2 col3
    4 xx xx
    4 xx xx
    2 xx xx
    2 xx xx
    3 xx xx
    4 xx xx

    So the idea is to have that macro called when the file is saved and if the all the duplicated values in col1 are not group together, then prevent the safe with an error message.

    I do already know how to called a macro before saving via Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    I need the macro.

    Thanks a lot.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,404

    Re: VBA Macro to prevent unsorted duplicated row

    Add filter in first row and sort data.

  3. #3
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: VBA Macro to prevent unsorted duplicated row

    How about auto-sorting the sheet in the BeforeSave macro (to ensure always correct)

    This will sort the data based on column A
    Please Login or Register  to view this content.
    Modify for more complex sorting etc
    If a response has helped then please consider rating it by clicking on *Add Reputation below the post
    When your issue has been resolved don't forget to mark the thread SOLVED (click Thread Tools at top of thread)

  4. #4
    Registered User
    Join Date
    04-19-2016
    Location
    Bruxelles
    MS-Off Ver
    2010
    Posts
    2

    Re: VBA Macro to prevent unsorted duplicated row

    zbor thanks for your reply, but my request deals with a vba macro.

    kevin# thanks for your reply, your post is the answer that I expected and it works like a charm.

  5. #5
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: VBA Macro to prevent unsorted duplicated row

    You are welcome. Thanks for the Reps.
    Please mark the thread as solved (see Thread Tools at top of thread)

+ 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. Mark duplicated or triplicated data-macro
    By sky123 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-27-2013, 07:07 AM
  2. Macro to ckeck duplicated file name
    By newapa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2012, 01:23 PM
  3. Need help in creating a macro that will read duplicated data
    By jwanch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2011, 04:11 PM
  4. Removing Duplicated Cells Macro
    By jfish in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2011, 04:35 PM
  5. How to prevent data in an excel file from being copied, printed or duplicated?
    By greentea2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2010, 01:44 AM
  6. Function/Macro To Determine High Values From Unsorted Array
    By damalco in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-08-2010, 11:40 AM
  7. macro to generate sorted table from unsorted list?
    By JGCA in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-14-2009, 11:36 AM
  8. Macro Help - Delete Duplicated Data
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-02-2005, 09:05 AM

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