+ Reply to Thread
Results 1 to 5 of 5

Type Mismatch error - extracting number macro

  1. #1
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Type Mismatch error - extracting number macro

    Dear all,

    I am writing to seek help, in help with "Type Mismatch error" in the macro below. I am trying to implement logic, where if value in column F, equals "1ma+89", then extract 89 only in column G. I also have other values in column F, where I have set specific rules for them, to extract numbers.

    I have attached a worksheet with example data and highlighted red cells, represent incorrect output from the macro.
    test2_14July.xlsm

    Please Login or Register  to view this content.
    Please advice, if I may be missing something in the code.

    Many thanks

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Type Mismatch error - extracting number macro

    I got the error in this line
    Please Login or Register  to view this content.

    I think you've missed teh isnumeric of the left dn,2
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Type Mismatch error - extracting number macro

    I got the error in this line
    Please Login or Register  to view this content.

    I think you've missed teh isnumeric of the left dn,2

  4. #4
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    Re: Type Mismatch error - extracting number macro

    Thank you for your reply and help. From your suggestion, I manage to solve the mismatch error. However, the macro is still producing incorrect value for value in column F "1ma+89", as 1+89, instead of extracting 89 only in column G.

    Please Login or Register  to view this content.
    Please advice further, if possible.
    Many thanks

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Type Mismatch error - extracting number macro

    Not sure how you're going to get 89. The string starts with a 1 but, more importantly:

    Please Login or Register  to view this content.

    So you can eliminate the + sign by making the line:

    Please Login or Register  to view this content.

    But that's going to give you 189 because you picked up the 1 from the first character.

    Edit:
    Please Login or Register  to view this content.
    will be false so you never get to test for "1ma+"

    You probably need to re-order your tests to check for the "anomalies" like "1ma+" and "S+" and "high" before trying to extract the numbers.


    Regards, TMS
    Last edited by TMS; 07-14-2014 at 06:02 AM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. [SOLVED] Concatenate macro Type Mismatch error
    By rdowney79 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-12-2014, 02:05 PM
  2. Getting Type Mismatch, Runtime Error 13 With This Macro
    By HowdeeDoodee in forum Excel General
    Replies: 16
    Last Post: 11-13-2012, 07:59 AM
  3. Re: Help with a macro- 'Run-Time error '13' Type Mismatch
    By pman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2012, 03:31 PM
  4. Testing value of string but its a number........gives type mismatch error
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-18-2011, 05:06 PM
  5. type mismatch error in Benford's law macro
    By Sody in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-24-2006, 06:10 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