Thread: help with loops
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick B[_6_] Rick B[_6_] is offline
external usenet poster
 
Posts: 12
Default help with loops

That helped. This is what I have:

Sub copyRange()

Dim v As Variant
Dim i As Integer
Dim intRow As Integer

intRow = 49
Do
intRow = intRow + 1
Loop Until Sheets(1).Cells(intRow, 1) = ""

v = Sheets(2).Range("C50:C70")

For i = LBound(v) To UBound(v)

If Not IsNull(v(i, 1)) Then
Sheets(2).Cells(intRow, 3) = v(i, 1)
intRow = intRow + 1
End If

Next

End Sub

However, the problem is that it runs flawlessly on the first execution,
however, on the secong, it rewrites over the same cells on Sheet1 instead of
finding the first empty cell. Not sure what I am doing wrong.

You have been extremely helpful

Thanks in advance.

-rick


"tolgag " wrote in message
...
Hi,

it's quita a simple chage :

I think the first setting is clear (v = Sheets(2).Range("a1:a100"))
Just change it to v = Sheets(2).Range("c20:c50")

The variable intRow is the cell, where it starts to look for the next
empty cell and as you see, it starts at 1. All you have to do is, start
searching at 20th cell.


---
Message posted from http://www.ExcelForum.com/