Suggesties | User Defined Functions |
Inleiding Voorbeeld Samenvoegen rij alle cellen gevulde cellen alle cellen, scheidingsteken gevulde cellen, scheidingsteken Samenvoegen kolom alle cellen gevulde cellen alle cellen, met scheidingsteken gevulde cellen, scheidingsteken Samenvoegen gebied alle cellen gevulde cellen alle cellen, scheidingsteken gevulde cellen, scheidingsteken afzonderlijke items in kolom afzonderlijke items in rij frekwentie kolom-items >1 frekwenties kolom-items langste tekenreeks in gebied |
Met VBA kun je eigen Excel'formules' maken. Die heten in Excel: User Defined Functions (UDF).In het lijstje met beschikbare funkteis vind je ze bij 'door gebruiker gedefinieerd' Die moet je altijd in een macromocule opslaan om ze beschikbaar te hebben in een werkblad. Het resultaat van een funktie krijg je terug als de naam van de funktie en kan tekst, getallen of een matrix zijn. Meestal moet je argumenten doorgeven waarmee de funktie kan gaan rekenen. In een cel in het werkblad kun je de funktie met de argumenten invoeren; daarna toont de cel het resultaat van de berekening. Plaats in een cel waarin je de samenvoeging van de cellen A1:E1 wil zien de funktie F_concatenaterow_snb' = F_concatenaterow_snb(A1:E1)
Function F_concatenaterow_snb(c01)
F_concatenaterow_snb = Join(Application.Index(c01.Value,1,0), "|")
End Function
Function F_concatenaterow_noblanks_snb(c01)
F_concatenaterow_noblanks_snb = Replace(Join(Filter(Split("~" & Join(Application.Index(c01.value,1,0), "~|~") & "~", "|"), "~~", False), "|"), "~", "")
End Function
Function F_concatenatecolumn_snb(c01)
F_concatenatecolumn_snb = Join(Application.Transpose(c01), "|")
End Function
Function F_concatenatecolumn_noblanks_snb(c01)
F_concatenatecolumn_noblanks_snb = Replace(Join(Filter(Split("~" & Join(Application.Transpose(c01), "~|~") & "~", "|"), "~~", False), "|"), "~", "")
End Function
Function F_concatenaterange_snb(c01)
For j = 1 To UBound(c01.Value)
End Functionc02 = c02 & "|" & Join(Application.Index(c01.Value, j), "|")
NextF_concatenaterange_snb = Mid(c02, 2)
Function F_concatenaterange_noblanks_snb(c01)
For j = 1 To UBound(c01.Value)
End Functionc02 = c02 & "~|~" & Join(Application.Index(c01.Value, j), "~|~")
NextF_concatenaterange_noblanks_snb = Replace(Join(Filter(Split(Mid(c02, 3) & "~", "|"), "~~", False), "|"), "~", "")
Function F_conc_row_sep_snb(c01,c03)
F_conc_row_sep_snb = Join(Application.Index(c01.value,1,0),c03)
End Function
Function F_conc_row_noblanks_sep_snb(c01,c03)
F_conc_row_noblanks_sep_snb = Replace(Join(Filter(Split("~" & Join(Application.Index(c01.value,1,0), "~|~") & "~", "|"), "~~", False),c03), "~", "")
End Function
Function F_conc_col_sep_snb(c01,c03)
F_conc_col_sep_snb = Join(Application.Transpose(c01),c03)
End Function
Function F_conc_col_noblanks_sep_snb(c01,c03)
F_conc_col_noblanks_sep_snb = Replace(Join(Filter(Split("~" & Join(Application.Transpose(c01), "~|~") & "~", "|"), "~~", False),c03), "~", "")
End Function
Function F_conc_range_sep_snb(c01,c03)
For j = 1 To UBound(c01.Value)
End Functionc02 = c02 &c03& Join(Application.Index(c01.Value, j),c03)
NextF_conc_range_sep_snb = Mid(c02, 2)
Function F_conc_range_noblanks_sep_snb(c01,c03)
For j = 1 To UBound(c01.Value)
End Functionc02 = c02 & "~|~" & Join(Application.Index(c01.Value, j), "~|~")
NextF_conc_range_noblanks_sep_snb = Replace(Join(Filter(Split(Mid(c02, 3) & "~", "|"), "~~", False),c03), "~", "")
Function F_count_distinct_snb(c01)
F_count_distinct_snb = Evaluate("Sum(N(countif(offset(" &c01.Cells(1).Address & ",,,row(" &c01.Address & "))," & c01.Address & ")=1))")
End Function
Function F_count_frequency1_items_snb(c01)
F_count_frequency1_snb = Evaluate("SUM(N(countif(" &c01.Address & "," &c01.Address & ")=1))")
End Function
Function F_count_distinct_multiples_snb(c01)
F_count_distinct_multiples_snb = Evaluate("SUM(N(countif(" &c01.Address & "," &c01.Address & ")>1)*N(countif(offset(" &c01.Cells(1).Address & ",,,row(" &c01.Address & "))," &c01.Address & ")=1))")
End Function
Function F_count_distinct_multiples_freq_snb(c01,x)
count_distinct_multiples_freq_snb = Evaluate("SUM(N(countif(" &c01.Address & "," &c01.Address & ")=" &x& ")*N(countif(offset(" &c01.Cells(1).Address & ",,,row(" &c01.Address & "))," &c01.Address & ")=1))")
End Function
Function F_longest_string_snb(c01)
F_longest_string_snb = Evaluate("Max(len(" &c01.Address & "))")
End Function |