jkpieterse
Terugkerende gebruiker
- Lid geworden
- 18 mei 2015
- Berichten
- 2.984
@EvR: Kan je mijn methode ook eens timen (heeft geen zin als ik het doe, kan je niet vergelijken als het niet dezelfde machine e.d. was)?
Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
Privacywetgeving
Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.
Sub DoItMyWay()
Application.ScreenUpdating = False
With ThisWorkbook.Sheets("Eindresultaat")
.UsedRange.Clear
With ThisWorkbook.Sheets("Draaitabel").PivotTables(1)
.RefreshTable
.TableRange2.Copy
End With
.Cells(1).PasteSpecial 12
With .UsedRange
.Columns(1).SpecialCells(4).FormulaR1C1 = "=R[-1]C"
.Columns(3).Insert
.Columns(3).Formula = "=A1&B1"
.Columns(3).NumberFormat = "@"
.Value = .Value
.Cells(1, 3) = "string"
.Columns.AutoFit
End With
End With
Application.ScreenUpdating = True
End Sub
Sub M_snb_eenlussig()
sn = Sheets("Input_van_VPIG").Cells(1).CurrentRegion
With CreateObject("scripting.dictionary")
For j = 2 To UBound(sn)
c00 = sn(j, 1) & "_" & sn(j, 2) & "_" & sn(j, 1) & sn(j, 2)
.Item(c00) = Val(.Item(c00)) + sn(j, 3) & "_" & c00
Next
sn = .items
End With
With CreateObject("New:{8BD21D20-EC42-11CE-9E0D-00AA006002F3}")
.List = sn
Sheets("output_voor_analyse").Cells(1).Resize(.ListCount) = .List
End With
Application.DisplayAlerts = False
Sheets("output_voor_analyse").Cells(1, 1).CurrentRegion.Columns(1).TextToColumns , , , , 0, 0, 0, 0, -1, "_"
End Sub
Sub M_snb_evaluate()
Sheets("input_van_VPIG").Activate
sn = [index(A2:A2000&"_"&B2:B2000&"_"&A2:A2000&B2:B2000&"_"&sumifs(C2:C2000,A$2:A$2000,A2:A2000,B2:B2000,B2:B2000),)]
With CreateObject("scripting.dictionary")
For Each it In sn
x0 = .Item(it)
Next
Sheets("output_voor_analyse").Cells(1, 20).Resize(.Count) = Application.Transpose(.keys)
End With
Application.DisplayAlerts = False
Sheets("output_voor_analyse").Cells(1, 20).CurrentRegion.Columns(1).TextToColumns , , , , 0, 0, 0, 0, -1, "_"
End Sub
Sub hsv()
sn = Sheets("input_van_VPIG").Cells(1).CurrentRegion
Set dic = CreateObject("scripting.dictionary")
For i = 2 To UBound(sn)
dic.Item(sn(i, 1) & "_" & sn(i, 2) & "_" & sn(i, 1) & sn(i, 2)) = dic.Item(sn(i, 1) & "_" & sn(i, 2) & "_" & sn(i, 1) & sn(i, 2)) + sn(i, 3)
sn(dic.Count, 2) = dic.keys()(dic.Count - 1)
sn(dic.Count, 1) = dic.Item(dic.keys()(dic.Count - 1))
Next
With Sheets("output_voor_analyse").Cells(1)
.Resize(dic.Count, 2) = sn
.CurrentRegion.Columns(2).TextToColumns , , , , 0, 0, 0, 0, -1, "_"
End With
End Sub
Sub M_hsv_snb()
sn = Sheets("input_van_VPIG").Cells(1).CurrentRegion.Resize(, 4)
With CreateObject("scripting.dictionary")
For j = 2 To UBound(sn)
c00 = sn(j, 1) & sn(j, 2)
.Item(c00) = .Item(c00) + sn(j, 3)
sn(.Count, 1) = sn(j, 1)
sn(.Count, 2) = sn(j, 2)
sn(.Count, 3) = c00
sn(.Count, 4) = .Item(c00)
Next
Sheets("output_voor_analyse").Cells(1, 30).Resize(.Count, UBound(sn, 2)) = sn
End With
End Sub
Zette me aan het denken tot:
hsv_snb 4,835938
hsv na een aantal minuten maar afgekapt
Verbaasde mij ook, hoewel de uitkomst in PowerQuery meteen in een opgemaakte tabel staat, geen VBA nodig is en wellicht nog wat andere voordelen heeft. Maar ik had het sneller verwachtsnb zei:Wat me wel verbaast is, dat het script duidelijk sneller ......... suboptimale techniek. (correct me if I'm wrong)
Sub M_snb_querytable()
Sheet3.QueryTables.Add("ODBC;DSN=Excel files;DBQ=" & ThisWorkbook.FullName, Sheet3.Cells(1, 10), "SELECT afne, arti, afne&arti, aant FROM `Input_van_VPIG$` ").Refresh False
End Sub
Sheet3.QueryTables.Add("ODBC;DSN=Excel files;DBQ=" & ThisWorkbook.FullName, Sheet3.Cells(1, 10), "SELECT afne, arti ,afne&arti, sum(aant) FROM `Input_van_VPIG$` GROUP BY afne, arti, afne&arti ").Refresh False
7,902344 (nieuwe query)
6,640625 (bestaande refresh)
Sub M_snb_listobject()
With Sheet3.ListObjects.Add(0, "ODBC;DSN=Excel files;DBQ=" & ThisWorkbook.FullName, True, xlYes, Sheet3.Cells(1, 10)).QueryTable
.CommandText = "SELECT afne, arti ,afne&arti, sum(aant) FROM `Input_van_VPIG$` GROUP BY afne, arti, afne&arti "
.Refresh False
End With
End Sub
Sub M_snb_querytable_002()
With ThisWorkbook.Connections.Add("snb_dicht", " ", "ODBC;DSN=Excel files;DBQ=" & ThisWorkbook.FullName, "SELECT afne, arti ,afne&arti, sum(aant) FROM `Input_van_VPIG$` GROUP BY afne, arti, afne&arti ").ODBCConnection
Sheet3.QueryTables.Add(.Connection, Sheet3.Cells(1, 10), .CommandText).Refresh False
End With
End Sub
M_snb_listobject 7,230469
M_snb_querytable_002 8,507813
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.