Issue: same named cells in two different workbooks

Gringoire

Board Regular
Joined
Nov 18, 2016
Messages
71
Office Version
  1. 365
Platform
  1. Windows
Hello guys,
I have to programmatically copy and paste some ranges (sheet rows) from an Excel file to another Excel file.
During the Copy & Paste procedure, the code stops and Excel asks for choosing if maintain the old reference or use the new one for the cells having the same name in both files.

I must avoid that the routine stops waiting for User input and force it to always choose the new reference, but I have no idea on how to proceed.
do you have some hints?

The code is a simple
VBA Code:
Selection.Insert Shift:=xlDown

Thank you.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try this one

It sounds like you want to suppress the "Update Values" prompt that appears when copying and pasting cells from one Excel file to another. You can do this programmatically by disabling the alert dialogs. Here's how you can achieve this in VBA:

```vba
VBA Code:
Application.DisplayAlerts = False
' Your copy and paste code here
Application.DisplayAlerts = True
```

This code turns off alert dialogs, so Excel won't prompt you when it encounters the same named cells. Just make sure to turn them back on by setting `Application.DisplayAlerts = True` after you've finished the copy and paste operation. This will ensure that other alerts, such as overwrite confirmation, are not suppressed after this specific operation.
 
Upvote 0
Thanks for your prompt reply but it does not works.
VBA Code:
Application.DisplayAlerts = False
works if there is no decision to get.
In this case the code cannot decide by himself which reference should be used and it stops anyway.

I had a similar issue in the past when the code stopped to ask for a choice about the printer to be used. In that case I solved simply assigning a printer as default printer.
In this case I do not know how to programmatically "assign" the new workbook as default reference for the named cells coming from the old one.
 
Upvote 0

Forum statistics

Threads
1,215,124
Messages
6,123,190
Members
449,090
Latest member
bes000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top