Removing Duplicates against Criteria (VBScript)

MyrenG1

New Member
Joined
Jul 2, 2018
Messages
11
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
So this is going to be a challenge, I am looking for a button/Vb script that exports raw data in the below formats on a separate sheet (Detail Export).

Change date/time format to "dd_mm_yyyy".

Remove Duplicate values, See below for details.

Keep Duplicates if:

<style type="text/css">table.tableizer-table{ font-size: 12px; border: 1px solid #CCC ; font-family: Arial, Helvetica,sans-serif; } .tableizer-table td{ padding:4px; margin:3px; border: 1px solid #CCC ;} .tableizer-table th{ background-color: #104E8B ; color:#FFF; font-weight: bold; }</style>
Type
ID
Version
Date/Time
Field
User

Word Doument

1
231
01-06-2018 09:53:28BST
Removed Text
Jane
Word Doument

1
231
01-06-2018 09:53:28 BST
Added Word

Jane
Word Doument

1
231
01-06-201809:53:28 BST
Modified Date
Jane
Word Doument

1
232
01-06-2018 09:53:28 BST
Removed Text

Steve
Word Doument

1
232
01-06-201809:53:28 BST
Added Word
Steve
Word Doument

1
232
01-06-2018 09:53:28 BST
Modified Date

Steve
Excel Sheet

1
231
01-06-2018 09:53:28 BST
Removed Text

Jane
Excel Sheet

1
231
01-06-2018 09:53:28 BST
Added Word

Jane
Excel Sheet

1
231
01-06-2018 09:53:28 BST
Modified Date

Jane
Excel Sheet

1
232
01-06-2018 09:53:28 BST
Removed Text

Steve
Excel Sheet

1
232
01-06-2018 09:53:28 BST
Added Word

Steve
Excel Sheet

1
232
01-06-2018 09:53:28 BST
Modified Date

Steve

<tbody>
</tbody>


Different User, Same ID, Different Version and Same day. So essentially above each user should have "one change" to their name instead of 3 each for that day for that 1 ID. But also have a "second change" for the different "Type" (Excel Sheet).

I am looking for the data exported to leave behind Type and Unique ID's against Version Number and Day.

Please let me know if you need any clarification.

I have VB script that works for Daily data, but this is required for Monthly Data spread which removed duplicates for the different days as it picks up the same ID against the User. In the "RawData" sheet, "Column A" is a Concatenate of "Column C and G" (ID and Name).

See Script
Code:
Sub Run()
'
' Run Macro
'

  Range("A2:G999999").Select
  Range("A2").Activate
   Application.CutCopyMode = False
    Selection.Copy
    Sheets("DetailExport").Select
   Range("A2").Select
   ActiveSheet.Paste
   Application.CutCopyMode = False
   ActiveSheet.Range("$A$1:$G$999999").RemoveDuplicatesColumns:=Array(3, 7), _
       Header:=xlYes
   Columns("F:F").Select
    Selection.InsertShift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.InsertShift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
   Columns("E:E").Select
   Selection.TextToColumns Destination:=Range("E1"),DataType:=xlFixedWidth, _
       FieldInfo:=Array(Array(0, 1), Array(10, 1), Array(19, 1)), TrailingMinusNumbers_
       :=True
   Columns("F:G").Select
   Range("G1").Activate
    Selection.DeleteShift:=xlToLeft
    Dim LR AsLong
    LR =Range("E" & Rows.Count).End(xlUp).Row
   Range("E2").FormulaR1C1 ="=LEFT(VLOOKUP(RC[-4],'RawData'!C[-4]:C,5,false),10)"
   Range("E2").AutoFill Destination:=Range("E2:E" &LR)
   Sheets("Summary").Select
   ActiveWorkbook.RefreshAll
   Range("A1").Select
End Sub
 
Last edited by a moderator:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,215,529
Messages
6,125,344
Members
449,219
Latest member
Smiqer

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top