Wednesday, 25 September 2019

excel - VBA - Too Slow with With and selection Command. How Can I optimize it better to run faster?

This is how to remove the selection and to speed up the process:



With Sheets(Currentsheetname).Range("A" & SelRowNumber + 1 & ":A" & lastrow).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="Remove"

.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Warning"
.InputMessage = ""
.ErrorMessage = "Please select a value from the list available in the selected cell."
.ShowInput = True
.ShowError = True
End With



Always try to avoid seletction and activation in VBA.

No comments:

Post a Comment