04. januar 2011 - 08:46Der er
7 kommentarer og 1 løsning
Sammenligning makro driller
Tilbage i 2003 fik jeg hjælpe her på eksperten til at lave en makro som skulle sammenligne 2 * 20.000 rækker det var lidt en udfordring dengang fordi det krævede 400.000.000 udregninger af en computer med 2-300 MB ram. - men det lykkedes takket være bl.a. excel hajen kabbak
Mit problem er nu jeg har totalt glem hvordan man bruger den og har derfor brug for lidt hjælp.
Jeg har: kaldt mine ark "NyListe" "FastListe" og "ResultatListe" Har copy/paste makro´erne ind i et modul
Hvad så nu ?
---- Sub Init_Compare() '''Dim af variable Dim TB1 As Range, TB2 As Range, TB3 As Range, TB4 As Range Dim Temp As Range Dim IndexCol1 As Long, IndexCol2 As Long Dim StartTid As Double Dim ReturnArray As Variant
Set TB1 = Sheets("NyListe").Range("A1:H1") '1. inputområde Set TB2 = Sheets("FastListe").Range("A1:H1") '2. inputområde
Set TB3 = Sheets("ResultatListe").Range("A1") '1. outputområde Set TB4 = Sheets("ResultatListe").Range("A1") '2. outputområde IndexCol1 = 2 'anden kolonne i TB1 (B) IndexCol2 = 2 'anden kolonne i TB2 (B)
Set ReturnArray = Nothing Application.ScreenUpdating = True MsgBox "Færdig tid : " & Timer - StartTid Sheets("ResultatListe").Select End Sub
Sub DoCompare2Lists(WS1 As Range, WS2 As Range, SearchCol1 As Long, SearchCol2 As Long, aForskel As Variant) Dim xCol As Scripting.Dictionary Dim Fundet As Boolean, Last1 As Long, Last2 As Long Dim Cols2 As Long Dim i As Long, z As Long, x As Long
Set xCol = New Scripting.Dictionary Cols2 = WS2.Columns.Count Last1 = WS1.Cells(65536, SearchCol1).End(xlUp).Row Last2 = WS2.Cells(65536, SearchCol2).End(xlUp).Row ReDim aForskel(Last2, Cols2) z = 0
On Error Resume Next With WS1 For i = 1 To Last1 xCol.Add Item:=CStr(.Cells(i, SearchCol1)), Key:=CStr(.Cells(i, SearchCol1)) Next End With With WS2 For i = 1 To Last2 Fundet = xCol.Exists(CStr(.Cells(i, SearchCol2))) If Not Fundet = True Then z = z + 1 For x = 1 To Cols2 aForskel(z, x) = .Cells(i, x) Next End If Fundet = True Next End With Set xCol = Nothing End Sub
I dette særtema om aspekter af AI ser vi på skiftet fra sprogmodeller til AI-agenter, og hvordan virksomheder kan navigere i spændet mellem teknologisk hastighed og behovet for menneskelig kontrol.
fandt lige en "bak" har lavet - han har vist iøvrigt også lavet den første.
Option Explicit Option Base 1 Sub Init_Compare() '''Dim af variable Dim TB1 As Range, TB2 As Range, TB3 As Range Dim Temp As Range Dim IndexCol1 As Long, IndexCol2 As Long Dim StartTid As Double Dim ReturnArray As Variant
With Application Set TB1 = .InputBox("Marker overskrift af område 1", Type:=8) TB1.Parent.Activate Set Temp = .InputBox("Marker 1.celle i sammenligningskolonnen", Type:=8) IndexCol1 = Temp.Column - TB1.Column + 1 Set TB2 = .InputBox("Marker overskrift af område 2", Type:=8) TB2.Parent.Activate Set Temp = .InputBox("Marker 1.celle i sammenligningskolonnen", Type:=8) IndexCol2 = Temp.Column - TB2.Column + 1 Set TB3 = .InputBox("Marker 1. celle af resultatområde", Type:=8) TB3.Parent.Activate End With
MsgBox "Færdig tid : " & Timer - StartTid Set ReturnArray = Nothing End Sub
Sub DoCompare2Lists(WS1 As Range, WS2 As Range, SearchCol1 As Long, SearchCol2 As Long, aForskel As Variant) Dim xCol As Scripting.Dictionary Dim Fundet As Boolean, Last1 As Long, Last2 As Long Dim Cols2 As Long Dim i As Long, z As Long, x As Long
Set xCol = New Scripting.Dictionary Cols2 = WS2.Columns.Count Last1 = WS1.Cells(65536, SearchCol1).End(xlUp).Row Last2 = WS2.Cells(65536, SearchCol2).End(xlUp).Row ReDim aForskel(Last2, Cols2) z = 0
On Error Resume Next With WS1 For i = 1 To Last1 xCol.Add Item:=CStr(.Cells(i, SearchCol1)), Key:=CStr(.Cells(i, SearchCol1)) Next End With With WS2 For i = 1 To Last2 Fundet = xCol.Exists(CStr(.Cells(i, SearchCol2))) If Not Fundet = True Then z = z + 1 For x = 1 To Cols2 aForskel(z, x) = .Cells(i, x) Next End If Fundet = True Next End With Set xCol = Nothing End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.