+ Reply to Thread
Results 1 to 5 of 5

Vba error 400 in macro using excel 2007

  1. #1
    Registered User
    Join Date
    02-24-2014
    Location
    Bishops Stortford, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Question Vba error 400 in macro using excel 2007

    I have a macro for splitting worksheets to form separate list of data dependant of what column is specified.
    This has worked perfectly well in 2003 and 2007 worksheets.
    However I recently had to split a worksheet that had originally been an xml file which I had imported into excel. Apart from a couple of minor formmatting issues, all the data imported successfully. Upon running the macro, it keeps stopping with an error 400 message box.
    Upon stepping through the macro I found that the error occured when it came to the following line of code

    If .FilterMode Then .ShowAllData


    It filtered correctly but when it came to ShowAllData, the sheet remained blank and kicked in the Error 400.
    I've set the AutoFilterMode to false earlier in the macro.

    Any ideas would be most helpful

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Vba error 400 in macro using excel 2007

    Hi, PeterJohns,

    you might like to consider to wrap teh code line with code.atgs.

    Without seeing all of your code or an example I would try to use
    Please Login or Register  to view this content.
    which would reset the Autofilter to none or use the same criteria columns again to get the information to be displayed again.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    02-24-2014
    Location
    Bishops Stortford, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Vba error 400 in macro using excel 2007

    Hi Holger, If only life was that simple.
    I tried running the macro by selecting another column to 'sort' by, this ran perfectly.
    This would suggest that the format for the column I need to sort by is the problem.
    I've so far tried changing the format from Text to General to Number, to no effect
    The column contains a specific code in the form 01-01, 01-02 etc upto 70-01, then there are some alphanumeric but at present i have left them out of the test.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Vba error 400 in macro using excel 2007

    Hi, PeterJohns,

    could you attach a sample workbook with some data and maybe a bit more of the code that causes the error as I´m pretty convinced that rebuilding a workbook for test won´t show that behaviour.

    Ciao,
    Holger

  5. #5
    Registered User
    Join Date
    02-24-2014
    Location
    Bishops Stortford, England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Vba error 400 in macro using excel 2007

    Holger,
    Here's the section of the code
    With ActiveWorkbook


    For x = 1 To ContList.Count

    If ContList(x) Like "*Dean *" Then
    Debug.Print "wait!"
    End If

    .Sheets(1).Copy After:=.Sheets(1)
    With .Sheets(2)
    .Name = Left(ContList(x), 31)
    .Cells(lastRow, SplitColNum).AutoFilter field:=SplitColNum, Criteria1:="<>" & ContList(x)
    .AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Delete
    If .FilterMode Then .ShowAllData
    .[a65536].End(xlUp).Select
    End With
    Attached Files Attached Files

+ 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. Macro from Excel 2007 now has error in 2010 - invalid command?
    By missyreiber in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-25-2013, 10:18 AM
  2. Replies: 1
    Last Post: 03-08-2012, 05:14 PM
  3. Runtime error 1004 using macro in excel 2007
    By CrazyHorse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-03-2011, 11:54 AM
  4. Excel 2007 pivot table/macro/Runtime error 1004
    By abalserv in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2010, 06:36 AM
  5. [SOLVED] Excel 2007 Beta 2 - Macro Run-time error '424' Object required
    By jcm21 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-16-2006, 02:20 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