• Status: Solved
• Priority: Medium
• Security: Public
• Views: 102

# 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

Thanks,
Montrof
0
montrof
• 2
• 2
1 Solution

Commented:
0

Author Commented:
Here is a sample
Sample.xlsm
0

Commented:
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
Loop
End Sub
``````

Saurabh...
0

Author Commented:
As Always thank you so much for your help

--Montrof
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.