+ Reply to Thread
Results 1 to 4 of 4

Runtime Error 1004 Excel 97

  1. #1
    Registered User
    Join Date
    05-08-2006
    Posts
    2

    Exclamation Runtime Error 1004 Excel 97

    Hi Hoping someone can help keep getting the following error when macro is ran. The Macro is:-

    Private Sub CommandButton1_Click()
    Sheets("Input Data").Select
    ActiveSheet.Range("Import_Data").Select
    Selection.ClearContents
    Sheets("Input Data").Select
    ActiveSheet.Range("A1").Select
    Selection.QueryTable.Refresh BackgroundQuery:=False
    Sheets("Pivot Table").Select
    ActiveSheet.PivotTables("PivotTable2").RefreshTable
    Sheets("Macros").Select
    ActiveSheet.Range("A1").Select
    End Sub


    Please anyone help

  2. #2
    K Dales
    Guest

    RE: Runtime Error 1004 Excel 97

    If your Import-Data range includes the entire query results range, you may be
    erasing the query completely, so there is nothing left to refresh. If my
    guess is correct, this would be the line highlighted when the error occurs
    and you go to debug:
    Selection.QueryTable.Refresh BackgroundQuery:=False

    There is no need to erase a query range before refreshing. Excel will erase
    the old data as part of the refresh process.
    --
    - K Dales


    "missfitz" wrote:

    >
    > Hi Hoping someone can help keep getting the following error when macro
    > is ran. The Macro is:-
    >
    > Private Sub CommandButton1_Click()
    > Sheets("Input Data").Select
    > ActiveSheet.Range("Import_Data").Select
    > Selection.ClearContents
    > Sheets("Input Data").Select
    > ActiveSheet.Range("A1").Select
    > Selection.QueryTable.Refresh BackgroundQuery:=False
    > Sheets("Pivot Table").Select
    > ActiveSheet.PivotTables("PivotTable2").RefreshTable
    > Sheets("Macros").Select
    > ActiveSheet.Range("A1").Select
    > End Sub
    >
    >
    > Please anyone help
    >
    >
    > --
    > missfitz
    > ------------------------------------------------------------------------
    > missfitz's Profile: http://www.excelforum.com/member.php...o&userid=34234
    > View this thread: http://www.excelforum.com/showthread...hreadid=539881
    >
    >


  3. #3
    Tim Williams
    Guest

    Re: Runtime Error 1004 Excel 97

    Which line is the error on?

    --
    Tim Williams
    Palo Alto, CA


    "missfitz" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hi Hoping someone can help keep getting the following error when macro
    > is ran. The Macro is:-
    >
    > Private Sub CommandButton1_Click()
    > Sheets("Input Data").Select
    > ActiveSheet.Range("Import_Data").Select
    > Selection.ClearContents
    > Sheets("Input Data").Select
    > ActiveSheet.Range("A1").Select
    > Selection.QueryTable.Refresh BackgroundQuery:=False
    > Sheets("Pivot Table").Select
    > ActiveSheet.PivotTables("PivotTable2").RefreshTable
    > Sheets("Macros").Select
    > ActiveSheet.Range("A1").Select
    > End Sub
    >
    >
    > Please anyone help
    >
    >
    > --
    > missfitz
    > ------------------------------------------------------------------------
    > missfitz's Profile: http://www.excelforum.com/member.php...o&userid=34234
    > View this thread: http://www.excelforum.com/showthread...hreadid=539881
    >




  4. #4
    Registered User
    Join Date
    05-08-2006
    Posts
    2

    Thanks

    Thanks I will give that a try and let you know what happens.


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1