Excel VBA: Add checkbox, speedup process
Jeg har lavet en VBA kode i min excel dokument som indsætter forskellige checkboxes i specifikke celler i et andet worksheet.Dette virker fint, men selve processen tager RIGTIG LANG tid. Det er bl.a. som om at den hopper frem og tilbage mellem de 2 worksheets.
Er der en måde jeg kan gøre processen hurtigere???
[code]
' Add checkboxes
Set PasteLineCheckbox = PasteLineStart.Offset(12, 0)
' Aftale Checkboxes
With .OLEObjects.Add(ClassType:="Forms.Checkbox.1", link:=False, DisplayAsIcon:=False, Left:=PasteLineCheckbox.Offset(0, 0).Left + 3, Top:=PasteLineCheckbox.Offset(0, 0).Top + 1, Width:=224.25, Height:=13.5)
.Object.Caption = "Timeaftale": .Placement = xlMoveAndSize: .LinkedCell = PasteLineCheckbox.Offset(0, 0).Address: .Object.Value = False: .Object.BackStyle = 0: .Object.SpecialEffect = 0: .Object.Font.Size = 10: .Object.Font.Bold = True
End With
With .OLEObjects.Add(ClassType:="Forms.Checkbox.1", link:=False, DisplayAsIcon:=False, Left:=PasteLineCheckbox.Offset(1, 0).Left + 3, Top:=PasteLineCheckbox.Offset(1, 0).Top + 1, Width:=224.25, Height:=13.5)
.Object.Caption = "Forretningsføreraftale": .Placement = xlMoveAndSize: .LinkedCell = PasteLineCheckbox.Offset(1, 0).Address: .Object.Value = False: .Object.BackStyle = 0: .Object.SpecialEffect = 0: .Object.Font.Size = 10: .Object.Font.Bold = True
End With
With .OLEObjects.Add(ClassType:="Forms.Checkbox.1", link:=False, DisplayAsIcon:=False, Left:=PasteLineCheckbox.Offset(2, 0).Left + 3, Top:=PasteLineCheckbox.Offset(2, 0).Top + 1, Width:=224.25, Height:=13.5)
.Object.Caption = "Anlægsbudget": .Placement = xlMoveAndSize: .LinkedCell = PasteLineCheckbox.Offset(2, 0).Address: .Object.Value = False: .Object.BackStyle = 0: .Object.SpecialEffect = 0: .Object.Font.Size = 10: .Object.Font.Bold = True
End With
' Status Checkboxes
With .OLEObjects.Add(ClassType:="Forms.Checkbox.1", link:=False, DisplayAsIcon:=False, Left:=PasteLineCheckbox.Offset(0, 2).Left + 3, Top:=PasteLineCheckbox.Offset(0, 2).Top + 1, Width:=224.25, Height:=13.5)
.Object.Caption = "Ønske": .Placement = xlMoveAndSize: .LinkedCell = PasteLineCheckbox.Offset(0, 2).Address: .Object.Value = False: .Object.BackStyle = 0: .Object.SpecialEffect = 0: .Object.Font.Size = 10: .Object.Font.Bold = True
End With
With .OLEObjects.Add(ClassType:="Forms.Checkbox.1", link:=False, DisplayAsIcon:=False, Left:=PasteLineCheckbox.Offset(1, 2).Left + 3, Top:=PasteLineCheckbox.Offset(1, 2).Top + 1, Width:=224.25, Height:=13.5)
.Object.Caption = "Pågår, Internt (Igang)": .Placement = xlMoveAndSize: .LinkedCell = PasteLineCheckbox.Offset(1, 2).Address: .Object.Value = False: .Object.BackStyle = 0: .Object.SpecialEffect = 0: .Object.Font.Size = 10: .Object.Font.Bold = True
End With
[/code]
På forhånd mange tak for hjælpen :)