Vous êtes sur la page 1sur 27

aa10 bb9

aa1 bb90
aa8 bb7
aa7 bb6
aa6 bb5
aa5 bb4
aa1 bb90
aa4 bb3
aa1 bb90
aa18 bb17
aa1 bb16
aa17 bb16
aa13 bb12
aa12 bb11
aa11 bb10
aa1 bb90
aa2 bb1
aa1 bb90

Sub M_remove_duplicate_records()
sn = Sheets("uniek").Cells(1).CurrentRegion

With CreateObject("scripting.dictionary")
For j = 1 To UBound(sn)
.Item(sn(j, 1)) = Application.Index(sn, j, 0)
Next

Sheets("unique").Cells(1, 4).Resize(.Count, UBound(sn, 2)) = Application.Index(.Items, 0, 0)


End With
End Sub

start
aa10 bb9 aa10
aa1 bb9 aa11
aa8 bb7 aa12
aa7 bb6 aa13
aa6 bb5 aa17
aa5 bb4 aa18
aa1 bb4
aa4 bb3
aa1 bb3
aa18 bb17
aa1 bb16
aa17 bb16
aa13 bb12
aa12 bb11
aa11 bb10
aa1 bb1
aa2 bb1
aa1 bb0

Sub M_remove_records()
sn = Sheets("remove records").Cells(1).CurrentRegion.Resize(, 3)
sp = Sheets("remove records").Cells(1, 5).CurrentRegion

With CreateObject("scripting.dictionary")
For j = 1 To UBound(sn)
.Item(sn(j, 1)) = Application.Index(sn, j, 0)
Next

For j = 1 To UBound(sp)
.Remove sp(j, 1)
Next

Sheets("remove records").Cells(1, 10).Resize(.Count, UBound(sn, 2)) = Application.Index(.Items, 0, 0)


End With
End Sub

start
aa10 bb9 aa10 cc1
aa1 bb9 aa1 cc2
aa8 bb7 aa8 cc3
aa7 bb6 aa7 cc4
aa6 bb5 aa6 cc5
aa5 bb4 aa5 cc6
aa1 bb4 aa1 cc7
aa4 bb3 aa4 cc8
aa1 bb3 aa1 cc9
aa18 bb17 aa18 cc10
aa1 bb16 aa1 cc11
aa17 bb16 aa17 cc12
aa13 bb12 aa13 cc13
aa12 bb11 aa12 cc14
aa11 bb10 aa11 cc15
aa1 bb1 aa1 cc16
aa2 bb1 aa2 cc17
aa1 bb0 aa1 cc18

Sub M_complement_records()
sn = Sheets("complement").Cells(1).CurrentRegion.Resize(, 3)
sp = Sheets("complement").Cells(1, 5).CurrentRegion

With CreateObject("scripting.dictionary")
For j = 1 To UBound(sn)
.Item(sn(j, 1)) = Application.Index(sn, j, 0)
Next

For j = 1 To UBound(sp)
st = .Item(sp(j, 1))
st(3) = sp(j, 2)
.Item(sn(j, 1)) = Application.Index(st, 0, 0)
Next

Sheets("complement").Cells(1, 10).Resize(.Count, UBound(sn, 2)) = Application.Index(.Items, 0, 0)


End With
End Sub

start
aa2 3/18/2013 aa2 18-03-2013
aa1 3/17/2013 aa1 19-03-2010
aa12 3/15/2013 aa12 15-03-2013
aa6 3/14/2013 aa6 16-03-2011
aa1 3/12/2013 aa4 9/3/2013
aa6 3/11/2013 aa5 7/3/2013
aa1 3/10/2013 aa10 2/3/2013
aa4 3/9/2013 aa7 5/3/2012
aa1 3/8/2013 aa8 4/3/2012
aa5 3/7/2013 aa17 13-03-2010
aa6 3/6/2013
aa1 3/3/2013
aa10 3/2/2013
aa7 3/5/2012
aa8 3/4/2012
aa6 3/16/2011
aa1 3/19/2010
aa17 3/13/2010

Sub M_filter_records_lowest_value_in_columnB()
With Sheets("filter least recent").Cells(1)
.CurrentRegion.Sort .Offset(, 1), 2
sn = .CurrentRegion
End With

With CreateObject("scripting.dictionary")
For j = 1 To UBound(sn)
.Item(sn(j, 1)) = Application.Index(sn, j, 0)
Next

Sheets("filter least recent").Cells(1, 6).Resize(.Count, UBound(sn, 2)) = Application.Index(.Items, 0, 0)


End With
End Sub

start
0, 0)
aa17 3/13/2010
aa1 3/19/2010
aa6 3/16/2011
aa8 3/4/2012
aa7 3/5/2012
aa10 3/2/2013
aa1 3/3/2013
aa6 3/6/2013
aa5 3/7/2013
aa1 3/8/2013
aa4 3/9/2013
aa1 3/10/2013
aa6 3/11/2013
aa1 3/12/2013
aa6 3/14/2013
aa12 3/15/2013
aa1 3/17/2013
aa2 3/18/2013

Sub M_filter_records_highest_value_in_columnB()
With Sheets("filter most recent").Cells(1)
.CurrentRegion.Sort .Offset(, 1)
sn = .CurrentRegion
End With

With CreateObject("scripting.dictionary")
For j = 1 To UBound(sn)
.Item(sn(j, 1)) = Application.Index(sn, j, 0)
Next

Sheets("filter most recent").Cells(1, 6).Resize(.Count, UBound(sn, 2)) = Application.Index(.Items, 0, 0)


End With
End Sub

start
, 0)
country gender occupation name

Private Sub Worksheet_Activate()


Cells(2, 1) = " "
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)


If Target.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub
If Intersect(Range("A2,B2,D2,F2"), Target) Is Nothing Then Exit Sub

sn = Cells(1, 11).CurrentRegion

With CreateObject("scripting.dictionary")
For j = 2 To UBound(sn)
Select Case Target.Address
Case "$A$2"
x0 = .Item(sn(j, 1))
Target = ""
Case "$B$2"
If Target.Value = sn(j, 1) Then x0 = .Item(sn(j, 2))
Case "$D$2"
If Target.Offset(, -2) = sn(j, 1) And Target.Value = sn(j, 2) Then x0 = .Item(sn(j, 3))
Case "$F$2"
If Target.Offset(, -4) = sn(j, 1) And Target.Offset(, -2).Value = sn(j, 2) And Target.Value = sn(j, 3) Then x0 = .Item(sn(j, 4))
End Select
Next

Target.Offset(, IIf(Target.Column = 1, 1, 2)).Validation.Modify 3, , , Join(.keys, ",")


If Target.Address = "$B$2" Then Range("D2,F2,H2").ClearContents
End With
End Sub
country gender occupation name
NL m agent aa56
D m chauffeur aa57
B m direkteur aa58
L m organist aa59
B v agent aa60
D v docent aa61
L v agent aa62
B v chauffeur aa63
NL m docent aa64
NL v chauffeur aa65
NL v secretaris aa66

ue = sn(j, 3) Then x0 = .Item(sn(j, 4))


aa1 aa2 aa3 aa4
aa2 aa3 aa4 aa5
aa3 aa4 aa5 aa6
aa4 aa5 aa6 aa7
aa5 aa6 aa7 aa8
aa6 aa7 aa8 aa9
aa7 aa8 aa9 aa10
aa8 aa9 aa10 aa11
aa9 aa10 aa11 aa12
aa10 aa11 aa12 aa13
aa11 aa12 aa13 aa14

bb2 bb3 bb4 bb5


bb3 bb4 bb5 bb6
bb4 bb5 bb6 bb7
bb5 bb6 bb7 bb8
bb6 bb7 bb8 bb9
bb7 bb8 bb9 bb10

Sub M_combine_ranges()
With CreateObject("scripting.dictionary")
For Each ar In Columns(1).SpecialCells(2).Areas
For j = 1 To ar.Rows.Count
.Item(.Count) = Application.Index(ar.Resize(, 4), j, 0)
Next
Next
Cells(1, 6).Resize(.Count, 4) = Application.Index(.Items, 0, 0)
End With
End Sub

start
Sub M_combine_arrays()
With CreateObject("scripting.dictionary")
sn = Cells(1).CurrentRegion
sp = Cells(14, 1).CurrentRegion

For j = 1 To UBound(sn)
.Item(.Count) = Application.Index(sn, j, 0)
Next
For j = 1 To UBound(sp)
.Item(.Count) = Application.Index(sp, j, 0)
Next

sq = Application.Index(.Items, 0, 0)
End With

ListBox1.List = sq
End Sub

start
Sub M_integration()
With CreateObject("scripting.dictionary")
For Each sh In Sheets
If sh.Name <> "integration" And sh.UsedRange.Count > 1 Then .Item(sh.Name) = sh.UsedRange
Next

' Sheets.Add.Name = "integration"

For Each it In .Items


Sheets("integration").Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(it), UBound(it, 2)) = it
Next
End With
End Sub

start
nge

2)) = it
Sub M_integration_csv()
MsgBox Replace("Adapt the paths in the macro.~~Use a folder that contains only a few csv-bestanden for testing", "~",
vbLf), , "Attention"

c00 = "G:\OF\"
sn = Split(CreateObject("wscript.shell").exec("cmd /c Dir """ & c00 & "*.csv"" /b").stdout.readall, vbCrLf)

With CreateObject("scripting.dictionary")
For j = 0 To UBound(sn)
.Item(sn(j)) = GetObject(c00 & sn(j)).Sheets(1).UsedRange.Value
GetObject(c00 & sn(j)).Close False
Next

' Sheets.Add.Name = "integration csv"

For Each it In .Items


Sheets("integration csv").Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(it), UBound(it, 2)) = it
Next
End With
End Sub

start
ting", "~",
aa10
aa1
aa8
aa7
aa6
aa5
aa1
aa4
aa1
aa18
aa1
aa17
aa13
aa12
aa11
aa1
aa2
aa1

Sub M_unique_in_combobox()
sn = Cells(1, 9).CurrentRegion

With CreateObject("scripting.dictionary")
For Each it In sn
x0 = .Item(it)
Next

ComboBox1.List = .keys
End With
End Sub

start
aa1_aa2_aa3_aa4_aa5|bb1_bb2_bb3_bb4_bb5|cc1_cc2_cc3_cc4_cc5

Sub M_split_textstring()
With CreateObject("scripting.dictionary")
For Each it In Split("aa1_aa2_aa3_aa4_aa5|bb1_bb2_bb3_bb4_bb5|cc1_cc2_cc3_cc4_cc5", "|")
.Item(.Count) = Application.Index(Split(it, "_"), 1, 0)
Next

Sheets("split textstring").Cells(1).Resize(.Count, UBound(.Item(1))) = Application.Index(.Items, 0, 0)


End With
End Sub

start
Private dict_actX As Dictionary

Private Sub Worksheet_Activate()


Set dict_actX = CreateObject("scripting.diction

For Each it In Array("TextBox1", "TextBox2", "Te


Set dict_actX(it) = Sheets("ActiveX control").OL
Next
End Sub

Private Sub Textbox1_change()


M_controle
End Sub
Private Sub TextBox2_Change()
M_controle
End Sub
Private Sub TextBox3_Change()
M_controle
End Sub
Private Sub ComboBox4_Change()
M_controle
End Sub
Private Sub ComboBox5_Change()
M_controle
End Sub

Private Sub M_controle()


y = True
For Each it In dict_actX.Items
y = y * (it.Object.Value <> "")
Next

Sheets("ActiveX control").CommandButton1.Visib
End Sub
X As Dictionary

rksheet_Activate()
= CreateObject("scripting.dictionary")

Array("TextBox1", "TextBox2", "Textbox3", "Combobox4", "Combobox5")


X(it) = Sheets("ActiveX control").OLEObjects(it)

tbox1_change()

tBox2_Change()

tBox3_Change()

mboBox4_Change()

mboBox5_Change()

controle()

dict_actX.Items
bject.Value <> "")

eX control").CommandButton1.Visible = y
In macromodule sheet_exists

Public sheetss As New Dictionary

Sub M_sheets()
For Each sh In Sheets
x0 = sheetss.Item(sh.Name)
Next
End Sub

Sub M_sheet_exists()
If sheetss.Count = 0 Then M_sheets
MsgBox "Worksheet Unique exists: " & Format(sheetss.Exists("unique"), "Yes/no"), , "Does the worksheet Unique exist ?"
MsgBox "Worksheet Summary exists: " & Format(sheetss.Exists("summary"), "Yes/no"), , "Does the worksheet Summary exist ?"
End Sub

start
Unique exist ?"
heet Summary exist ?"
Public dict_ct As New Dictionary In the classmodule C_Eventcontrol

Private Sub UserForm_Initialize() Public WithEvents m_tekstvak As MSForms.TextBox


For Each ct In Controls Public WithEvents m_keusvak As MSForms.ComboBox
dict_ct.Add ct.Name, New C_Eventcontrol
Private Sub m_tekstvak_Change()
Select Case TypeName(ct) With m_tekstvak
Case "TextBox" .Text = UCase(.Text)
Set dict_ct(ct.Name).m_tekstvak = ct If Not TypeName(.Parent) = "Worksheet" Then .Pa
Case "ComboBox" End With
Set dict_ct(ct.Name).m_keusvak = ct End Sub
End Select
Next Private Sub m_keusvak_Change()
End Sub With m_keusvak
.Value = UCase(.Value)
If Not TypeName(.Parent) = "Worksheet" Then .Pa
End With
End Sub
start
Eventcontrol

ekstvak As MSForms.TextBox
eusvak As MSForms.ComboBox

k_Change()

ext)
(.Parent) = "Worksheet" Then .Parent.Caption = .Name

k_Change()

Value)
(.Parent) = "Worksheet" Then .Parent.Caption = .Name
Public dict_ac As New Dictionary In the classmodule C_Eventcontrol

Private Sub Worksheet_Activate() Public WithEvents m_tekstvak As MSForms.TextBox


For Each ct In OLEObjects Public WithEvents m_keusvak As MSForms.ComboBox
dict_ac.Add ct.Name, New C_Eventcontrol
Private Sub m_tekstvak_Change()
Select Case TypeName(ct.Object) With m_tekstvak
Case "TextBox" .Text = UCase(.Text)
Set dict_ac(ct.Name).m_tekstvak = ct.Object If Not TypeName(.Parent) = "Worksheet" Then .P
Case "ComboBox" End With
Set dict_ac(ct.Name).m_keusvak = ct.Object End Sub
End Select
Next Private Sub m_keusvak_Change()
End Sub With m_keusvak
.Value = UCase(.Value)
If Not TypeName(.Parent) = "Worksheet" Then .P
End With
End Sub
_Eventcontrol

tekstvak As MSForms.TextBox
keusvak As MSForms.ComboBox

ak_Change()

Text)
e(.Parent) = "Worksheet" Then .Parent.Caption = .Name

ak_Change()

.Value)
e(.Parent) = "Worksheet" Then .Parent.Caption = .Name

Vous aimerez peut-être aussi