macro to automatically select an option when the dialog box opens up

Deepas

New Member
Joined
Mar 2, 2021
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi there, i am relatively new to macros.
I have this macro in place to copy the data from one work to another which runs fine. But everytime I run the macros I have a dialog box that opens up in the source sheet, which asks if I need to update the external links. I need to manually click Update, and then the continue option for the macro to run. how can we tune the macro to automatically select Update option when the dialog box opens up and then the continue option.

Sub Macro9()

Dim SrcWB As Workbook
Dim dstWB As Workbook
Dim SrcWS As Worksheet
Dim dstWS As Worksheet
Dim Lastrow As Long, i As Long

Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False

Set dstWB = ThisWorkbook
Set dstWS = dstWB.Worksheets("Sheet1")
Set SrcWB = Workbooks.Open("Z:\Weekly Tracker\Deepa\pairs final\final\final\US pairs\US BANK PAIRS.xlsm")
Set SrcWS = SrcWB.Worksheets("live Sheet")

SrcWS.Range("B5:O32").Copy
dstWS.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False
SrcWB.Close SaveChanges:=False
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

Thankyou in advance :)
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try:
VBA Code:
Sub Deepas_1()
   
    Dim v As Variant
    Const source_file As String = "Z:\Weekly Tracker\Deepa\pairs final\final\final\US pairs\US BANK PAIRS.xlsm"
   
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
        .DisplayAlerts = False
    End With

    With Workbooks.Open(source_file, True, True)
        v = .Sheets("live sheet").[B5:O32].Value
        ActiveWorkbook.Close
    End With
   
    With ThisWorkbook.Sheets("Sheet1")
        .Cells(.Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(v, 1), UBound(v, 2)).Value = v
    End With
   
    With Application
        .ScreenUpdating = True
        .EnableEvents = True
        .DisplayAlerts = True
    End With

    Erase v

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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