VBA Offseting Active Cell (i) in For/If Staement

  • Hi Forum,


    I have the following code that looks for the first non blank cell in Col("I"). Once it finds that cell it completes various Copy/Paste actions, when these are complete I would like to find the next non blank cell, starting 4 rows down rather than in the very next row. I have tried inculding an offset at the end of the if statement which does select the correct cell, however on the Next i it still goes to the next row down instead of the offset row selected. Please help!



    Currently it only searchs Col("I"). I would also love some assistance in offsetting the column from I to LastColumn, this would include making Range("I1").Copy change to active column.


    Thank you in advance for any assistance offered.

  • For you current code you need to change

    Code
    ActiveCell.Offset(4, 0).Activate


    to

    Code
    i = i + 3


    Note that you add 3 not 4 because the value of i will be increased by 1 as the loop iterates.


    If I correctly understand what you mean by "this would include making Range("I1").Copy change to active column." then this should be what you need

    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.

  • i = i + 3 works perfectly!! Thank you so much.
    Introducing LC to get it to move columns is along the same lines as I was thinking. I've tried to run it however it bugs out at

    Code
    If Range(ii & i).Value <> "" Then


    I'm trying it on a Mac instead of the Microsoft I have at work, not sure if that has anything to do with it.


    Any ideas or alternatives to get that working?

  • Can you attach a sample workbook please.

    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.

  • Try this

    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.

  • Thanks for that.


    Back at work and I've managed to make it work.


    The final code is:


    Thank you for all your help! Its been very much appreciated.

  • You're welcome

    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!