Consulting

Results 1 to 2 of 2

Thread: Solved: Refresh data upon open

  1. #1
    VBAX Contributor
    Joined
    Mar 2009
    Location
    Indiana
    Posts
    113
    Location

    Exclamation Solved: Refresh data upon open

    Hello,

    I am trying to figure out how to get this data that i have imported from access to refesh when the file is opened. Can anyone let me know how to refresh this data when the workbook is opened, then run a sub called SortAndColor. If possible, it would be nice for it to not prompt for automatic refresh. If someone could help me this would be great.

    I was using the following but it will not process past the first line (Selection.QueryTable.Refresh BackgroundQuery:=False).

    Private Sub Workbook_open()
    Selection.QueryTable.Refresh BackgroundQuery:=False
    Call SortAndColor
    End Sub

    Thanks!

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Selection is not set on opening. Define your range, something like
    [VBA]
    Sheets(2).Range("A1:G500").QueryTable.Refresh BackgroundQuery:=False

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •