niklasbp
05-15-2015, 05:02 AM
Hey you all
i have a code in vba to compare cells, but it is super slow, and i'm sure that there is a better way to do it
what i have is 5 columns with random phone numbers, the problem is that sometimes the same number occurs twice in the same row
Therefore i have created a macro to clear the cell, if the number is already once in a row
my code looks like this:
Sub ARun()
Application.ScreenUpdating = False
Call FK
'Call FN
'Call FQ
'Call FT
'Call FW
'Call KN
'Call KQ
'Call KT
'Call KW
'Call NQ
'Call NT
'Call NW
'Call QT
'Call WQ
'Call TW
End Sub
Function FK()
Dim startRow As Integer
startRow = 1
Dim row As Integer
row = startRow
Dim bRow As Integer
Do While (Worksheets("Ark1_Levering").Range("F" & row).Value <> "")
Dim aVal As String
Dim bVal As String
aVal = Worksheets("Ark1_Levering").Range("F" & row).Value
bVal = Worksheets("Ark1_Levering").Range("K" & row).Value
bRow = startRow
Do While (Worksheets("Ark1_Levering").Range("F" & bRow).Value <> "")
If (aVal = bVal) Then
Worksheets("Ark1_Levering").Range("K" & row).Clear
Exit Do
End If
bRow = bRow + 1
Loop
row = row + 1
Loop
End Function
then i have a function for every two cells i want to compare, which is just a replica of the function FK you see above
i was thinking that a possible solution was to make a list instead, where every row is a new list, where if the same number is twice it will clear one of them, but i don't know how to do it
i have +10.000 rows btw
best regards
/the vba newb
i have a code in vba to compare cells, but it is super slow, and i'm sure that there is a better way to do it
what i have is 5 columns with random phone numbers, the problem is that sometimes the same number occurs twice in the same row
Therefore i have created a macro to clear the cell, if the number is already once in a row
my code looks like this:
Sub ARun()
Application.ScreenUpdating = False
Call FK
'Call FN
'Call FQ
'Call FT
'Call FW
'Call KN
'Call KQ
'Call KT
'Call KW
'Call NQ
'Call NT
'Call NW
'Call QT
'Call WQ
'Call TW
End Sub
Function FK()
Dim startRow As Integer
startRow = 1
Dim row As Integer
row = startRow
Dim bRow As Integer
Do While (Worksheets("Ark1_Levering").Range("F" & row).Value <> "")
Dim aVal As String
Dim bVal As String
aVal = Worksheets("Ark1_Levering").Range("F" & row).Value
bVal = Worksheets("Ark1_Levering").Range("K" & row).Value
bRow = startRow
Do While (Worksheets("Ark1_Levering").Range("F" & bRow).Value <> "")
If (aVal = bVal) Then
Worksheets("Ark1_Levering").Range("K" & row).Clear
Exit Do
End If
bRow = bRow + 1
Loop
row = row + 1
Loop
End Function
then i have a function for every two cells i want to compare, which is just a replica of the function FK you see above
i was thinking that a possible solution was to make a list instead, where every row is a new list, where if the same number is twice it will clear one of them, but i don't know how to do it
i have +10.000 rows btw
best regards
/the vba newb