Run macro between number range

  • I am new to macros and need help finishing it.


    I have a spreadsheet with numbers in column A, the numbers range from 1-40 and go in order least to greatest. Typically have about 10 numbers in column A.


    I need a macro to have a popup and ask for a number input, then to take that number and find the next largest number that exists in column A. then to run another macro “Insert_divison”



    Example: User inputs “3” I need it to look for 4 then 5 then 6… until it finds a match.



    Currently my macro only is looking for one number past the input. (user input 3, if 4 does not exist the marco will error out)



    Sub Insert_DivisionTEST()


    myvalue = InputBox("Insert Division Number")


    Dim findrow As Long, findrow2 As Long


    findrow = Range("A:A").Find(myvalue + 1, Range("A1")).Row


    Range("A" & findrow - 1).Select


    Call Insert_Division


    ActiveCell.Offset(1).Value = myvalue


    End Sub

  • What is your Insert_Division macro?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Attach a sample workbook, together with a sheet showing required result.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

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