Excel Looping Question on multiple ranges...

M

Marve

I have a code that loops on selected range ex. A1:B4.. the looping
starts from A1:B1 then it goes on the second row that is A2:B2 (it
starts from left to right and goes on the second row)...Now my question
is, would there be a way VBA to know when it starts to process a new
row like A3:B3? Here's my code: What I want to do is for it to be smart
enought to populate values at the start of every new row based on the
range. I appreciate any help...

For Each r In Sheets(5).Range(A1:B4).Cells
If (I want that piece of code entered here, if there is)
Then
xlapp.ActiveWorkbook.Worksheets(4).Select
Range("A1").Select
Do Until IsEmpty(ActiveCell.Offset(x, 0))
x = x + 1
Loop
n = 1
End If
i = 0
sArray = Split(r & "ý", "ý")
With xlapp
.ActiveWorkbook.Worksheets(4).Select
last = UBound(sArray) - 1
Do Until i > last
Cells(i + 1 + x, n).FormulaR1C1 = CStr(sArray(i))
i = i + 1
Loop
.ActiveWorkbook.Worksheets(5).Select
End With
n = n + 1
'Next t
't = t + 1
Next r
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top