Forum Discussion

DougPCI's avatar
DougPCI
Copper Contributor
Jul 21, 2020
Solved

Excel help

Hey excel community,   I am currently running into a small design flaw from an original project I created a few months ago.  Now I am looking for some advice on how to improve upon it.  I have thes...
  • Bennadeau's avatar
    Jul 22, 2020

    Hi DougPCI,

    If you can add a macro to your "source" spreadsheet (spreadsheetA.xlsx), you can try the following and run it whenever you update the source spreadsheet. You can even run this on a timer if you want.

     

    Macro

    Public Sub refreshXLS()
    Path = "C:\test\Excel\spreadsheetB.xlsx" 'the workbook path you want to refresh

    With Application
    .DisplayAlerts = False
    .ScreenUpdating = False
    .EnableEvents = False
    .AskToUpdateLinks = False
    End With

    Workbooks.Open Path
    ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources
    ActiveWorkbook.Close True

    With Application
    .DisplayAlerts = True
    .ScreenUpdating = True
    .EnableEvents = True
    .AskToUpdateLinks = True
    End With
    End Sub

    Public Sub refreshXLS()
    Path = "C:\test\Excel\destination" 'the workbook path you want to refresh

    With Application
    .DisplayAlerts = False
    .ScreenUpdating = False
    .EnableEvents = False
    .AskToUpdateLinks = False
    End With

    Workbooks.Open Path
    ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources
    ActiveWorkbook.Close True

    With Application
    .DisplayAlerts = True
    .ScreenUpdating = True
    .EnableEvents = True
    .AskToUpdateLinks = True
    End With
    End Sub

    ---

     

    If Macro is not an option, perhaps you could leave the spreadsheetB.xlsx open all the time. Probably not the the most efficient method but it will work.

Resources