View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
fedude fedude is offline
external usenet poster
 
Posts: 74
Default simple nested loop question

Here is my single row loop. I need a way to increment rDest to
A4..A5....A21 and run this loop each time:

Public Sub writeRange()

Dim rDest As Range
Dim i As Long

With Range("A1").Resize(1, 26)
Set rDest = Range("A3").Resize(.Rows.Count, .Columns.Count)
For i = 1 To .Count
If IsNumeric(.Cells(i).Value) Then
If .Cells(i).Value = 1 Then
rDest(i) = Cells(i).Value
End If
End If
Next i
End With
End Sub


"Hemant_india" wrote:

hi
see if this helps
dim rang as range
set rang = activesheet.range('put your range here')
for each cell in rng
do whatever u want to do with cell
next
--
hemu


"fedude" wrote:

I have a range that is a single row A1..Z1. I need to loop through this
range interrogating every cell in this range and if true, then write a number
in the corresponding cell in a similarly sized array (A3..Z3). I think I
know how to do this, but then I need to move the destination down one row
(A4..Z4) and repeat. I need to drop down a row 18 times.

So I need a nested loop, but I don't know how to increment the destination
in the outer loop.

noob