• VBA – Excel forumla referencing a different workbo

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » VBA – Excel forumla referencing a different workbo

    • This topic has 4 replies, 2 voices, and was last updated 17 years ago.
    Author
    Topic
    #450818

    I have an Access app that builds excel workbooks. In 1 I have a cell that needs to reference a cell in another workbook on my hard drive.

    I have the formula built like this:

    ='[WorkbookName.xls]SheetName’!$A$1

    the formula works, but when stepping thru the code, as soon as it does this line:
    xlapp.ActiveCell.Value = “='[WorkbookName.xls]SheetName’!$A$1”

    Excel open the Open File dialog.

    Not good for automating.

    Is there a way around this?

    Viewing 0 reply threads
    Author
    Replies
    • #1108505

      If the other workbook is not open, you should specify the full path:

      xlapp.ActiveCell.Value = "='C:MyFolder[WorkbookName.xls]SheetName'!$A$1"

      You must, of course, substitute the actual path. Otherwise Excel cannot resolve the external reference.

      • #1108507

        Hans,

        If I could hug you right now I would.

        Consider yourself hugged!!

        • #1108560

          Is it possible to have that cell = the VALUE rather than be linked?

          • #1108563

            You could try this:

            With xlapp.ActiveCell
            .Value = "='C:MyFolder[WorkbookName.xls]SheetName'!$A$1"
            .Value = .Value
            End With

    Viewing 0 reply threads
    Reply To: VBA – Excel forumla referencing a different workbo

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: