Forum Discussion

Sumit_Bhokare's avatar
Sumit_Bhokare
Brass Contributor
Jan 17, 2024

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 from master template due to merge cell, I'm getting pop up alert. 

"Merging cells only keeps the upper-left value and discards other values."

 

Is there any way I can turn this alert off while creating a copy?

      • djclements's avatar
        djclements
        Bronze 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

Resources