ExcelBanter

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

Frank

Loop
 
Hi All,

I have a fairy easy question but I can't find the correct answer:

I have 2 excelsheets File1.xls and File2.xls
On File1.xls there is one cell (C6) that I want to copy to file2.xls in
Range A if there is a value in Range B from file2.xls

So I need to create a loop function but I can't find the right one.

Can anyone help me with this?

Thanks!

BR

Dave Peterson

Loop
 
Sometimes you don't have to loop:



Dim wks1 as worksheet
dim wks2 as worksheet
dim LastRow as long

set wks1 = workbooks("file1.xls").worksheets("sheet999")
set wks2 = workbooks("file2.xls").worksheets("sheet888")

with wks2
lastrow = .cells(.rows.count,"B").end(xlup).row
.range("a1:A" & lastrow).value = wks.range("c6").value
end with



Frank wrote:

Hi All,

I have a fairy easy question but I can't find the correct answer:

I have 2 excelsheets File1.xls and File2.xls
On File1.xls there is one cell (C6) that I want to copy to file2.xls in
Range A if there is a value in Range B from file2.xls

So I need to create a loop function but I can't find the right one.

Can anyone help me with this?

Thanks!

BR


--

Dave Peterson


All times are GMT +1. The time now is 12:26 PM.

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