vba code working but not when i start from 0

  • ma1h

    g30 to 35 works

    ma1hg30
    ma1hg31
    ma1hg32
    ma1hg33
    ma1hg34
    ma1hg35

    however

    ma1h

    9C0 to 5 does not

    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!
    #VALUE!

    unless u start with 9c1 but not zero


    when i use this code


    • Best Answer

    There is no row 0 in Excel, so this approach will not work for that currently. You could add 1 to both x(1) and x(2) and subtract it in the evaluation:


    Code
    LastR.Resize(val(x(2)) - val(x(1)) + 1) = Evaluate("""" & pref & """&row(" & x(1) + 1 & ":" & x(2) + 1 & ")-1")

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Glad we could help. :)

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

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