Macro to search column for matching value and add timestamp

  • I have a macro that is supposed to search for a range of values in workbooks range k4:k43 and when it finds those in workbook1 column B, it puts a timestamp in column D of the same row. With this code I am getting a Compile Error Next Without For error. Can anyone help me out on this please?

    Images

    • Document111.docx
  • Hello,


    In an Excel Forum ... it would seem quite obvious ... to attach ... well ... an Excel file ...;)

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • Edited once, last by Carim: Added Code Tags ().

  • As a first step ...line #18 ... replace nn by mm ...


    sh_2.Cells(i, 4).Value = Format$(Now(), "yyyy-mm-dd hh:mm:ss")

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • nn 00-59 (Minute of hour, with a leading zero)
    mm 00-59 (Minute of hour, with a leading zero). Only if preceded by h or hh


    To answer your question ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!