+ Reply to Thread
Results 1 to 4 of 4

Select Method of Range Class failed error 400

  1. #1
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Select Method of Range Class failed error 400

    I received a 400 error so i put in an error trap to see what the error was. below is my code and the error is saying "Select Method of Range Class failed."

    I think it is having trouble selecting the columns but i dont know why
    Please Login or Register  to view this content.
    Thanks so much for your help
    Last edited by JosephP; 11-06-2012 at 05:37 PM. Reason: code tags - PLEASE USE THEM IN FUTURE :-)

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Select Method of Range Class failed error 400

    Hi,

    what exactly do you want your macro to do? I don't know where it fails, but I have some points to add:
    1. You don't need to select a cell to copy it or assign its value to a variable. Selecting slows the macro down a lot. Instead of
    Please Login or Register  to view this content.
    you could use this:
    Please Login or Register  to view this content.
    2. You declared your variables as string (text). Be aware that the cell contents you assign them to will be also in text format!

    3. This line kind of confuses me:
    Please Login or Register  to view this content.
    What exactly do you want to select? The code for selecting the cell right to the activecell is simply
    Please Login or Register  to view this content.
    4. If you want to know where your macro fails, you can go and exectue it step by step. Just press F8 while the code window is active and it will jump line by line. You can always check what happens after each step. Also, using messageboxes is useful as well. Try inserting lines like
    Please Login or Register  to view this content.
    to see what value is assigned to a variable. Maybe it's not what you would expect.

    Also, please use code tags on the forum for better readability. Hope I helped a little. Cheers!

  3. #3
    Registered User
    Join Date
    02-26-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Select Method of Range Class failed error 400

    Thanks so i isolated the error and it is occuring when it trys to select the columns "Columns("A:AZ").select

    The purpose of this macro is to consolidate a lot of files into one on different tabs

  4. #4
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Select Method of Range Class failed error 400

    I think you have to select the worksheet first, before selecting the range (columns). Maybe something like this will work:
    Please Login or Register  to view this content.
    Which I think is totally the same as
    Please Login or Register  to view this content.
    Last edited by RHCPgergo; 11-06-2012 at 05:27 PM. Reason: grammar stuff

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