VBNewbiwe83
New Member
- Joined
- Aug 29, 2018
- Messages
- 11
Hi Guys,
I m new to VBA ode and created a tool where I have code linked to a active x control button that clears certain cells in my xslm workbook.
The problem I am having is the tool is running slowly once the button is clicked.
I also use another code to autofit row based on vlookup responses so not sure which one may be causing the problem:
Thanks for any help
I m new to VBA ode and created a tool where I have code linked to a active x control button that clears certain cells in my xslm workbook.
The problem I am having is the tool is running slowly once the button is clicked.
Code:
Private Sub CommandButton13_Click()
If MsgBox("Do you want to clear tool ready for a new call?", vbYesNo + vbQuestion, "***WARNING***") = vbYes Then
ActiveSheet.Unprotect "Experience"
Range("C18").ClearContents
Range("C20").ClearContents
Range("C24").ClearContents
Range("C26:C27").ClearContents
Range("C33").ClearContents
Range("C35").ClearContents
Range("C37").ClearContents
Range("C43").ClearContents
Range("C45").ClearContents
Range("C46").ClearContents
Range("C48").ClearContents
Range("C54").ClearContents
Range("C56:C57").ClearContents
Range("C59").ClearContents
Range("C61").ClearContents
Range("C63").ClearContents
Range("C69").ClearContents
Range("C75:C76").ClearContents
Range("C78:C80").ClearContents
Range("C82:C83").ClearContents
Range("C87:C89").ClearContents
Range("C92").ClearContents
Range("C12").Select
Selection.Copy
ActiveSheet.Protect "Experience", True, True
End If
End Sub
I also use another code to autofit row based on vlookup responses so not sure which one may be causing the problem:
Code:
Private Sub Worksheet_Calculate()
ActiveSheet.Unprotect "Experience"
Range("A19").Rows.AutoFit
Range("A21").Rows.AutoFit
Range("A25").Rows.AutoFit
Range("A28").Rows.AutoFit
Range("A34").Rows.AutoFit
Range("A36").Rows.AutoFit
Range("A38").Rows.AutoFit
Range("A44").Rows.AutoFit
Range("A47").Rows.AutoFit
Range("A49").Rows.AutoFit
Range("A55").Rows.AutoFit
Range("A58").Rows.AutoFit
Range("A60").Rows.AutoFit
Range("A62").Rows.AutoFit
Range("A64").Rows.AutoFit
Range("A70").Rows.AutoFit
Range("A77").Rows.AutoFit
Range("A81").Rows.AutoFit
Range("A84").Rows.AutoFit
Range("A92").Rows.AutoFit
ActiveSheet.Protect "Experience", True, True
End Sub
Thanks for any help