+ Reply to Thread
Results 1 to 10 of 10

Macro to match decimals, write only decimal match

  1. #1
    Forum Contributor
    Join Date
    07-01-2012
    Location
    ZA
    MS-Off Ver
    Excel 2013
    Posts
    300

    Macro to match decimals, write only decimal match

    Good day

    Wonder if someone can help me.Rep given for a solution -this is fairly straight forward for someone with excel vb skills.

    Got a spreadsheet Column A from number 1-80
    E1 I have the decimal I would like to match. As per my example 4.8. E2 is the devider as per example 5

    Looking for a macro that can go from 1 -80 and devide it through E2 to get the decimal value. If the decimal value last digit match the value in E1 the results must be written in H1 -if the number dnt match then the number must not be written.

    Example below

    G1 Value match decimal
    Decimal value 4.8 >>> 24 >>>>>>>>>>>>>>>24/5=4.8
    Matches 3.8 >>> 19
    5.8 >>> 29
    6.8 >>> 34
    7.8 >>> 39
    8.8 >>> 44

    E1 is a variable decimal and can change
    E2 devider is a variable and can change

    Only need G1 ascending the numbers that match the decimal

    Sample spreedsheet attached and any help appreciated + rep given to someone that can solve it.

    Many thanks

    Ricklou
    Attached Files Attached Files
    Last edited by ricklou; 07-22-2013 at 05:16 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Macro to match decimals, write only decimal match

    ricklou,

    Does it have to be a macro?
    You could use this formula in cell G2 and copy down to G81:
    Please Login or Register  to view this content.

    The formula will only pull the desired matches. Once they have all been found the remaining cells will be blanks.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Macro to match decimals, write only decimal match

    how many places (and btw who gives ***** about rep)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Contributor
    Join Date
    07-01-2012
    Location
    ZA
    MS-Off Ver
    Excel 2013
    Posts
    300

    Re: Macro to match decimals, write only decimal match

    Tigeravatar thanks works just as good as a macro...........thank you so much -rep given thanks

    But what if the cells to use change ? Tried it with another value but it dont work
    Last edited by ricklou; 07-23-2013 at 02:12 PM.

  5. #5
    Forum Contributor
    Join Date
    07-01-2012
    Location
    ZA
    MS-Off Ver
    Excel 2013
    Posts
    300

    Re: Macro to match decimals, write only decimal match

    Bump must have added it must be narrowed down to closest decimal........dont work on decimals ???

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Macro to match decimals, write only decimal match

    So you want it to match to a single digit when rounded? e.g. .16 would round and equal to .2?

  7. #7
    Forum Contributor
    Join Date
    07-01-2012
    Location
    ZA
    MS-Off Ver
    Excel 2013
    Posts
    300

    Re: Macro to match decimals, write only decimal match

    Yes please Tigeravatar.........I understand your logic but if it might be possible to use something that will round it off to closest decimal as per example -it works flawlessly for a rounded number!!!


    Decimal to match 6.2 >>>>>>>>>>>>>>>>>> 37
    Cells to use 6

  8. #8
    Forum Contributor
    Join Date
    07-01-2012
    Location
    ZA
    MS-Off Ver
    Excel 2013
    Posts
    300

    Re: Macro to match decimals, write only decimal match

    bump bump bump

  9. #9
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Macro to match decimals, write only decimal match

    ricklou,

    Attached is a modified version of the Decimals workbook you provided.
    I added a new item in column D, "Decimal places to round to" which has its value in cell E3 defined by this formula:
    Please Login or Register  to view this content.
    Basically it determines how many numbers are after the decimal point in cell E1. So with the 6.2 example, there is only 1 number after the decimal.
    This number is used to round to that many decimal places when dividing by the "cells to use" (denominator).

    This is the updated formula in cell G2 and copied down:
    Please Login or Register  to view this content.

    You can see that 37 is one of the returned values, which is expected.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    07-01-2012
    Location
    ZA
    MS-Off Ver
    Excel 2013
    Posts
    300

    Re: Macro to match decimals, write only decimal match

    Works like a charm thank you Tigeravatar

+ 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] Exact match with decimals doesn't work
    By benishiryo in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-09-2016, 12:35 AM
  2. How to write Macro or formula for finding 2criteria match values with comma in all cells
    By amolryeolekar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-26-2013, 02:24 AM
  3. How to write macro for find and match particular string in a column
    By narendrabr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2012, 08:20 AM
  4. how to write macro to find and match common string and write the keyword
    By narendrabr in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2012, 07:41 AM
  5. Macro to match values in 2 colums ,write matches
    By ricklou in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-03-2012, 01:55 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