Beste forumleden,
Graag zou ik op jullie kennis beroep willen doen om mijn macro sneller te laten werken (draait nu ongeveer 2 minuten).
De macro werd door mij opgemaakt via opnames en macro's die ik op het forum heb gevonden en zo tot een geheel heb omgevormd.
De macro loopt perfect alleen traag.
ALvast bedankt !!!!
met vriendelijke groet,
Ria
Graag zou ik op jullie kennis beroep willen doen om mijn macro sneller te laten werken (draait nu ongeveer 2 minuten).
De macro werd door mij opgemaakt via opnames en macro's die ik op het forum heb gevonden en zo tot een geheel heb omgevormd.
De macro loopt perfect alleen traag.
Code:
'Sub cleaning()
Application.ScreenUpdating = False
'
' cleaning Macro
'
'
ActiveWindow.ScrollWorkbookTabs Sheets:=1
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("cleaning").Select
Cells.Select
Application.CutCopyMode = False
Selection.UnMerge
ActiveWindow.SmallScroll Down:=1
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 1
Columns("D:J").Select
Selection.ColumnWidth = 6
Columns("K:AE").Select
Selection.ColumnWidth = 5
Columns("H:H").Select
Selection.Delete Shift:=xlToLeft
Columns("K:K").Select
Selection.Delete Shift:=xlToLeft
Columns("L:M").Select
Selection.Delete Shift:=xlToLeft
Range("D9:I232").Select
Dim C As Range, T As String, T2 As Integer, T3 As Integer
On Error Resume Next
Range("B9:AE800").Select
For Each C In Selection
C.Replace _
What:=Chr(160), _
Replacement:=Chr(32)
'vaste spaties omzetten in spaties
T = Trim(C.Value)
With Application.WorksheetFunction
T2 = .Find(".", T)
T3 = .Find(".", T, T2 + 1)
End With
If IsEmpty(C) Then
'overslaan lege cellen
ElseIf LCase(C.Value) Like "*[a-z]*" Then
'overslaan cellen met letters
ElseIf C.Value Like "*[@$#;:/\]*" Then
'overslaan tekens
ElseIf T3 - T2 = 2 Or T3 - T2 = 3 Then
'twee punten in een getal overslaan
Else
If C.Value Like "*.*" Then
C.Replace _
What:=".", _
Replacement:=""
End If
If IsNumeric(C) Then
'datum getallen negeren
C.NumberFormat = "general"
'celopmaak instellen
C.Value = C.Value * 1
End If
End If
Next
On Error GoTo 0
Range("I1").Select
ActiveCell.FormulaR1C1 = "1"
Range("I1").Select
Selection.Copy
Range("D9:I700").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "[h]:mm"
ActiveWindow.SmallScroll Down:=-15
Range("C8").Select
With Sheets("Cleaning")
For i = 700 To 8 Step -1
If .Cells(i, 3).Value = "" Then .Cells(i, 3).EntireRow.Delete
Next
End With
With Sheets("Cleaning")
For i = 700 To 8 Step -1
If .Cells(i, 11).Value = "" Then .Cells(i, 11).EntireRow.Delete
Next
End With
Range("B8:AA700").Select
With Selection.Font
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection
.VerticalAlignment = xlCenter
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("F11").Select
Columns("B:B").ColumnWidth = 9
Range("B2:K2").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("D3:I3").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("J3:AA3").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("D4:I4").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("J4:R4").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
Range("S4:AA4").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlTop
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Cells.Select
Selection.Copy
Sheets("input").Select
Cells.Select
ActiveSheet.Paste
Sheets("data").Select
Range("A2:A700").Select
Selection.Copy
Sheets("werkblad").Select
Range("B14").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("C14").Select
Sheets("startpagina").Select
Range("Z1").Select
Application.ScreenUpdating = True
End Sub
ALvast bedankt !!!!
met vriendelijke groet,
Ria
Laatst bewerkt door een moderator: