How to suppress the prompt from merging cells

S

Shue-Fen KIng

I am writing a macro to merge adjacent cells that have the
same values in the header row. But every merge prompts
the following message:

The selection contains multiple data values. Merging into
one cell will keep the upper-left most data only.

The choice is OK or Cancel.

What is the command to suppress this message and take OK
as default? Thanks.

Regards,
Shue-Fen
 
B

Bob Flanagan

Use

Application.displayalerts = false

to suppress alerts. Be sure to set back to true as it will remain false
after the macro quits. Then alerts like closing a file without saving will
not appear.

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
T

Tom Ogilvy

Another approach

Dim rng as Range, vVal as Variant
set rng = Range("A1:B9")
vVal = rng(1).Value
rng.clearContents
rng(1).value = vVal
rng.merge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top