+ Reply to Thread
Results 1 to 19 of 19

Incompatible Data Types

  1. #1
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    Incompatible Data Types

    Hi,

    I have a problem concerning datatypes for an if-loop, the failure message tells me "Datatypes incompatible" for this code-line:

    Please Login or Register  to view this content.
    Here is also the full context:

    Please Login or Register  to view this content.
    Thanks in advance for your help!
    Last edited by RoyMakaay1985; 09-09-2009 at 09:53 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Incompatible Data Types

    If you use "R" & last you need to use Range rather than Cells

    This will still fail if the contents of column R is empty or not a number.

    Also unless you have a named range "Last" you need to remove the quotes from the Copy statement. And from the calculation of 3+i

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    Hi Roy
    Try changing this line
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  4. #4
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: Incompatible Data Types

    Still yields the same error message, tried both your changes.

    But as I mentioned in my first post, the error message shows up in the code-line with "if"... So CW and the cell entry from "R" & last do not match. However, I formatted the Cell to be a number.

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    I think you need
    Please Login or Register  to view this content.
    Last edited by pike; 09-08-2009 at 04:35 AM. Reason: add code i = i + 1

  6. #6
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: Incompatible Data Types

    Ok, that helped. Now the copying works.

    However, only the last line in the file (Line 5000) is copied, even though (5000,18) is empty. The method is only supposed to check column R, if there is an entry. Does XX >= (number) yield true, when XX is empty?

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    Hey Roy
    Try changing
    Please Login or Register  to view this content.

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    or even
    remenbering the column and row positions are reversed when using cells ; 18 is column R
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: Incompatible Data Types

    Aha, that makes sense. I changed it to

    Please Login or Register  to view this content.
    so that the whole row is copied to the other sheet.

    Now everything works fine, except for that if the entry in "R" & u is empty, the row still gets copied... Why is that?

  10. #10
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    Roy
    try..

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: Incompatible Data Types

    Now it yields "Datatypes incompatible" again, when the if-loop starts to find empty cells

  12. #12
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    just had to have a cuppa..

    I would write script as
    Please Login or Register  to view this content.

  13. #13
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    Hey Roy

    the error in your code is Week in the inputbox needs to be "Week"

  14. #14
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    Dude if the code works can you please mark the post solved

  15. #15
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: Incompatible Data Types

    Sorry, didnt know about tis function. HJow do I mark it?

    Thanks for your help!

  16. #16
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: Incompatible Data Types

    Actually, I have one additional problem... I tried the same routine, but this time, I am looking for entries "X" and "x". The column is formatted as text, but again, the error message yields "Datatypes incompatible" Here's the code:

    Please Login or Register  to view this content.
    Thanks again for help!

  17. #17
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    Hi Roy
    just have to repeat statment for the or
    Please Login or Register  to view this content.
    to mark solved go back to your first post and edit
    then go advanced and change the prefix

  18. #18
    Registered User
    Join Date
    06-10-2009
    Location
    Germany
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: Incompatible Data Types

    Thanks a lot once again, it works

  19. #19
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Incompatible Data Types

    No thank you for marking the post solved
    Besides you had all the right code it just need a fine tune
    well done

+ 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