VBA Loop from active cell to next non empty cell in column

  • I want to create a loop which goes down from the active cell until the next non empty cell in column. I'm new in VBA and i don't know if it is possible.
    Code :


    Code
    For i = ActiveCell.Row To *** ''''' < --- here i want the row number of the next non empty cell on column B
    currentB.EntireRow.ClearContents
    Next i


    Until now i used IsEmpty(currentB) but in this case is not useful.


    Thank you

  • Hello,


    Not sure how ActiveCell can be used in a loop ... most probably you should look for another solution ...:wink:


    In order to locate the next non empty cell in Column B ... you could be testing the following :


    Code
    MsgBox Range("B4:B1000").Find(What:="*", After:=ActiveCell).Row


    Hope this will help

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

  • yes you are right, it only does something to the first row, but it doesn't do the same until the row with value. probably the idea is wrong. thank you very much

  • If you have not totally solved your problem ... feel free to attach your workbook with your next message along with an explanation of your expected results ... :wink:

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

  • works perfect thank you very much!!!!


    Glad you could fix your problem ... :wink:


    Thanks ... for your Thanks ..:smile:

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

  • What is a VBA to:

    select next cell in column A from current row, that contains some value in it

    So, if some values are in A rows 5, 15, 20, I'd want for next time macro is triggered (e.g. button in clicked) for next of those cells to be selected. And if active row happened to be in column different than A, for macro to still know that.

Participate now!

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