+ Reply to Thread
Results 1 to 3 of 3

Thread: Macro Help

  1. #1
    Registered User
    Join Date
    09-21-2011
    Location
    Portland, OR
    MS-Off Ver
    Excel 2007
    Posts
    1

    Macro Help

    I really need some help to figure out why I'm getting a runtime error on my macro when I wasn't getting one before. It's a refresh macro to extract data from our accounting software, clear, copy, paste, and combine data onto one combined data sheet.

    I'm getting Run-time error 91: Object variable or with block variable not set

    My macro is as follows:

    Sub REFRESH()
    '
    ' REFRESH Macro
    '
        Application.ScreenUpdating = False
    '
        Sheets("Actual Transactions").Select
        Selection.ListObject.QueryTable.REFRESH BackgroundQuery:=False
        Sheets("Actuals").Select
        Range("Table_Query_from_ADX_ELEMENTPOWER6[[#Headers],[COMPANY]]").Select
        Selection.ListObject.QueryTable.REFRESH BackgroundQuery:=False
        Sheets("Budget").Select
        Selection.ListObject.QueryTable.REFRESH BackgroundQuery:=False
        Sheets("Combined Data").Select
        Range("A2").Select
        Range(Selection, Selection.End(xlDown)).Select
        Range(Selection, Selection.End(xlToRight)).Select
        Application.CutCopyMode = False
        Selection.ClearContents
        Application.Goto Reference:="Table_Query_from_ADX_ELEMENTPOWER4"
        Selection.Copy
        Sheets("Combined Data").Select
        Range("A2").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Range("A2").Select
        Selection.End(xlDown).Select
        ActiveCell.Offset(1, 0).Select
        Application.Goto Reference:="Table_Query_from_ADX_ELEMENTPOWER6"
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Combined Data").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Sheets("ACTUAL DETAIL").Select
        Range("A8").Select
        ActiveSheet.PivotTables("PivotTable1").PivotCache.REFRESH
        Range("A1").Select
        Sheets("ACT VS BUD").Select
        Range("A11").Select
        ActiveSheet.PivotTables("PivotTable1").PivotCache.REFRESH
        Range("A1").Select
        
         Application.ScreenUpdating = False
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    1,957

    Re: Macro Help

    Hello and welcome to the forum - unfortunately you need to read the forum rules, because you've broken rule #1, which says that all threads must have a title descriptive of the problem and not a general request for help. If you edit your thread title to something less generic then I'm sure somebody will be able to sort you out. Thanks.

  3. #3
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,640

    Re: Macro Help

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    PLEASE PM WHEN YOU HAVE DONE THIS AND I WILL DELETE THIS POST
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0