loop through Cells

I want to loop through row 34 and if column A and B are not blank insert a value of Test in Column A Row 36 and Test2 in Row 37  Column A and then Row 36 Column B enter a 1 and then Row 37 Column B enter a  2.  Next it will move 3 columns from Column B which would be Column E and repeat the above and do this until Row 34 values are blank

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:
Can you update your sample file clearly showing what is before and after about what you want to do..as reading your comments i'm still not sure about what you are looking for...
montrofAuthor Commented:
Here is a sample
Saurabh Singh TeotiaCommented:
You can use the following code to do what you are looking for...

Sub updatedata()

    Dim i As Long, lcol As Long
    i = 1

    lcol = Cells(34, Cells.Columns.Count).End(xlToLeft).Column

    Do Until i > lcol

        If Cells(34, i).Value <> "" Then

            Cells(36, i).Value = "Test"
            Cells(37, i).Value = "Test2"
            Cells(36, i + 1).Value = 1
            Cells(37, i + 1).Value = 2
        End If

        i = i + 4
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
montrofAuthor Commented:
As Always thank you so much for your help

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.