+ Reply to Thread
Results 1 to 5 of 5

VBA run time error 1004

  1. #1
    Registered User
    Join Date
    12-13-2013
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2013
    Posts
    7

    Angry VBA run time error 1004

    I have the following code in MS Access. And I think something is getting weird defining between Access and Excel (I am looping through a subform, using the variable as a criteria in a filter on tables, and then pasting the table into excel, where I am making charts.) So I have no problem pasting values into excel, but When I try formatting it, I run into trouble. So, this code was actually working before, and I added some variables (See the first 4) to count the rows to select as the data source for the chart. Now, I am getting a run time error 1004 when arriving at the highlighted line. Please provide some feedback. Thanks!

    VBA.PNG

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: VBA run time error 1004

    What happens if you replace code starting from .SortFields.Clear with this?

    Please Login or Register  to view this content.
    I am assuming your table starts from Column A, hence .Columns(3) -> (C) for the sort key.
    多么想要告诉你 我好喜欢你

  3. #3
    Registered User
    Join Date
    12-13-2013
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: VBA run time error 1004

    Thanks, Millz. I am now bypassing the object defined error, but my column(3) is not sorting. So the command has no syntax error but is not functioning. Any suggestions on how to tweak your code?

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: VBA run time error 1004

    What if you run this code directly from Excel? Does it sort the data in the table? Maybe changing Header parameter to xlNo?

    I am purely guessing, I can't really imagine what's wrong without looking at anything. I tried the code directly in Excel, on a table and it works.

  5. #5
    Registered User
    Join Date
    12-13-2013
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: VBA run time error 1004

    Thanks for your persistence Millz, it was a "communication" issue between access and excel. So (I feel really stupid) I just added criteria to the $ field in my query and dumped into excel that way, allowing me to delete all these steps!! What a waste of time! Thanks again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Addon error : Run-time error '1004': Method 'MacroOptions' of object '_Application' failed
    By jtcoleman in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 02-05-2014, 12:23 PM
  2. Replies: 4
    Last Post: 11-15-2013, 05:03 PM
  3. VBA Code...error = run time error 1004 autofilter method of range class failed
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-15-2013, 04:49 PM
  4. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  5. [SOLVED] run-time error '1004': Application-defined or object-deifined error
    By rich5665@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2005, 05:05 PM

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