+ Reply to Thread
Results 1 to 7 of 7

Getting debug error when trying to do a "find"

  1. #1
    Registered User
    Join Date
    06-22-2007
    Posts
    42

    Getting debug error when trying to do a "find"

    Can anyone help me and show me where I am going wrong in my code:

    Please Login or Register  to view this content.
    What I am trying to do is look in the Backing Data sheet to see if a trainee in a certain week is there, if it is, some of the data needs to be amended, If it isn't, data needs to be inputted.

    I'm getting a run-time error '1004'
    Application-defined or object-defined error on the If Sheets(2).Cells(1, x) line

    (You'll be glad to know that they are sending me on training next month so I will stop asking so many questions!)

    Also, have I done this in the best way?

    Thanks in advance

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Don't use a Loop, it is unnecessarily slow. Your Rows count will always be over 2500 and also keep your Dims at the top for neatness. Also, you appear to be checking column 1 for both Trainee & date. Test this

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    format for cell command is
    cells(rownumber, column number or column letter)
    your command is going from column 2 to 2500

    try reversing your 1 & x

    Please Login or Register  to view this content.
    suggest you declare all your variables correctly & also look at adding other code to find last used row

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  4. #4
    Registered User
    Join Date
    06-22-2007
    Posts
    42
    Thanks Roy - but I get a run-time error '13' Type mismatch with that data on the

    Please Login or Register  to view this content.

    Thanks for your help mudraker as well

    (Edited as had put the wrong line in)
    Last edited by KA_Analyst; 07-24-2007 at 09:47 AM.

  5. #5
    Registered User
    Join Date
    06-22-2007
    Posts
    42
    Mudraker - thanks muchly, just switched the x & 1 and it now brings up the data entry form

  6. #6
    Registered User
    Join Date
    06-22-2007
    Posts
    42
    Next problem

    I have now got that working smoothly. However, when I have the data in there, it is recognising the name but not the date so bringing up the TraineeDetails form. If I take out the
    Please Login or Register  to view this content.
    then the AmendData form appears.

    Thanks for your patience

  7. #7
    Registered User
    Join Date
    06-22-2007
    Posts
    42
    Argh - it was something as simple as changing the '&' to 'And'


+ 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