Solved

Add extra step to current macro to auto update

Posted on 2013-01-23
5
271 Views
Last Modified: 2013-01-23
Hi Experts

I have the following vba which works perfectly fine...however, when the macro is running it has a intermediate step where the end user has to click the continue button as the following message appears...

This workbook contusions one or more links that cannot be updated

Click continue or edit workbook

I would like to select continue each time and incorporate a step into the current macro to do this automatically if possible



Option Explicit

Sub Conso()
Dim wbDst As Workbook
Dim wbSrc As Workbook
Dim wsSrc As Worksheet
Dim wsDst As Worksheet
Dim rngDst As Range
Dim strFilename As String
Dim strPath As String

    strPath = "C:\Documents and Settings\Test\"
   
    Set wbDst = ThisWorkbook  ' Workbooks.Open("C:\Documents and Settings\Test\Master Template.xls")

    Set wsDst = wbDst.Worksheets("cm1")

    Set rngDst = wsDst.Range("M18")

    strFilename = Dir(strPath & "*.xls")

    While strFilename <> ""

        If strFilename <> wbDst.Name Then

            Set wbSrc = Workbooks.Open(strPath & strFilename)

            Set wsSrc = wbSrc.Worksheets("cm")

            With wsSrc
                .Range("M18", .Range("M" & .Rows.Count).End(xlUp).Offset(0, 31)).Copy rngDst
            End With

            Set rngDst = wsDst.Range("M" & Rows.Count).End(xlUp).Offset(1)

            wbSrc.Close
        End If

        strFilename = Dir()

    Wend

End Sub
0
Comment
Question by:route217
  • 2
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
Shanan212 earned 250 total points
ID: 38810205
beginning of the macro, add this code

application.displayalerts = false

Open in new window

0
 
LVL 33

Assisted Solution

by:Norie
Norie earned 250 total points
ID: 38810207
You can change this,
Set wbSrc = Workbooks.Open(strPath & strFilename)

Open in new window

to this,
Set wbSrc = Workbooks.Open(strPath & strFilename, UpdateLinks:=3)

Open in new window

and the workbooks should open without a prompt and the links will be updated.
0
 
LVL 13

Expert Comment

by:Shanan212
ID: 38810223
Explanation of my answer:

It says you cannot update links, so regardless of that message and whether you click continue/not, you will not be updating links. This is probably because incorrect references/your source file is corrupted.

Therefore, setting the displayalerts to false will suppress this message.
0
 
LVL 33

Expert Comment

by:Norie
ID: 38810238
route217

Shanan212 has a good point.

I assumed you were just getting the update links message, not the can't update links message.
0
 

Author Comment

by:route217
ID: 38810290
All experts

Firstly thanks for the feedback - the question was to a refer if it appears... Poorly worded in my part - apologies..
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now