Forum Discussion
Sumit_Bhokare
Jan 17, 2024Brass Contributor
Disable alert message when merging cells
Hello team, I'm developing macro to generate separate copy from master template. within master template I have multiple worksheets and within worksheet few cells are merged. when I create copy ...
DadoSljeme
Feb 02, 2024Copper Contributor
djclements
Feb 02, 2024Silver Contributor
DadoSljeme That's Application.DisplayAlerts (with an s). Caution should be taken when disabling alerts... it's highly recommended to use error handling of some sort in order to make sure alerts are always turned back on. For example:
On Error Resume Next
Application.DisplayAlerts = False
'your code here...
Application.DisplayAlerts = True
If Err.Number <> 0 Then
MsgBox Err.Description, vbExclamation, "Runtime Error: " & Err.Number
Err.Clear
End If
On Error GoTo 0- DadoSljemeFeb 02, 2024Copper Contributor
Many thanks djclements of course Application.DisplayAlerts . I limit exactly only the area of the code, where I know there are Alerts that would block the flow but are safe to be turned off. Unfortunately Excel VBA does not offer to suppress them in the function itself, for example in the .merge method.