Incremental sequence between blanks

  • I'm in need of a script that increases a single increment from the upper value within blank rows.

    To go from this: ( in Column "D")


    _000




    _145

    _153

    _179





    _298






    _400


    ....to this:


    _000

    _001

    _002

    _003

    _145

    _153

    _179

    _180

    _181

    _182

    _183

    _298

    _299

    _300

    _301

    _302

    _303

    _400


    Thanks!

    Jeff

  • How about

    Code
    Sub JeffP()
       With Range("D1", Range("D" & Rows.Count).End(xlUp))
          .SpecialCells(xlBlanks).FormulaR1C1 = "=""_""&TEXT(SUBSTITUTE(R[-1]C,""_"","""")+1,""000"")"
          .Value = .Value
       End With
    End Sub

Participate now!

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