+ Reply to Thread
Results 1 to 3 of 3

Problem using "Cells" in "Range" "400" error

  1. #1
    Registered User
    Join Date
    08-21-2007
    Posts
    90

    Problem using "Cells" in "Range" "400" error

    I am having problems referrring to a range using .Cells

    If I try to use the remarked code (red text), it crashes with VBA "400" error for which I cannot find any explanation. It also crashes with same "400" message if I use a cells reference to a numeric column instead of "y").

    The code works using the black code: it loops a column in Sheet("Holidays") and loops a row in Sheet("Schedule"), then color fills 2 ranges in columns in Sheet("Schedule") when the values in 2 cells are equal.



    I have attached a scaled down version of my Workbook with this code.

    What am I doing wrong?

    Thanks,



    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by johnnywinter; 02-14-2009 at 05:46 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Problem using "Cells" in "Range" "400" error

    Hello johnny winter,

    When working with Cells you must remember if they are not qualified with a prefix then VBA assumes the cells are on the ActiveSheet. I have changed your code to use the With statement to ensure the cells belong to the correct worksheet.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    08-21-2007
    Posts
    90

    Re: Problem using "Cells" in "Range" "400" error

    Leith Ross,

    Thanks so much again.
    It always seems so simple when you explain it. after I have beat my head for hours trying to figure it out..

    I have received so much help on this board and have been pushed to learn so much.

    My many thanks,

    JW

+ 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