ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop (https://www.excelbanter.com/excel-programming/391731-loop.html)

Frank

Loop
 
Hi All,

I have got a question i can't find he

I have to files: File1.xls and File2.xls

In file1.xls there is a Cell (C6) that has a value I want to copy to
File2.xls in Column A as long there is a value in Column B of File2.xls
I need to do a loop but i can't get the correct code for it.

Can someone help me with this?

Thanks!

BR

Gary''s Student

Loop
 
Sub demo()
Workbooks("File2.xls").Activate
Sheets("Sheet1").Activate
For i = 1 To Rows.Count
If IsEmpty(Cells(i, "B")) Then
Exit For
End If
Next
i = i - 1

Set r2 = Range("A1:A" & i)
Set r1 = Workbooks("File1.xls").Sheets("Sheet1").Range("C6" )

r1.Copy r2
End Sub

--
Gary''s Student - gsnu200731


All times are GMT +1. The time now is 02:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com