Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi.
My problem is how to properly run a loop in one workbook that is referring to cells in another workbook. I know how to run loops when I am in only one workbook, but once I open another workbook, the macro references will point to the active workbook. In the sample code below, I want to run a loop from LastCell to LastRow in Demos.XLS. Inside this loop, I need an IF section of code that will search for a string in another workbook. If the value is found, then the values in Column 1,2,and 3 of that same row need to be copied to columns 2,3, and 4 of row "i" in the first workbook . Any help will be greatly appreciated! Thanks, Mike. Dim LastRow As Long Dim LastCell As Long Dim IP As String LastRow = Cells(Rows.Count, 10).End(xlUp).Row LastCell = Cells(Rows.Count, 1).End(xlUp).Row - 1 Workbooks.Open Filename:="C:\Documents and Settings\Mike\My Documents\IP Addresses.xls" For i = LastCell To LastRow ' in Demos.xls IP = Cells(i, 5) 'I need an IF section here that looks the IP value up in 'Column 4 of The IP Addresses workbook. If the value is found, then 'the values in Column 1,2,and 3 of that same row need to be copied to 'columns 2,3, and 4 of row "i" in the first workbook (Demos.xls). Next i |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Loop through folder of workbooks and add rows | Excel Worksheet Functions | |||
HELP!!!! Can't stop a loop (NOT an infinite loop) | Excel Programming | |||
loop through workbooks | Excel Programming | |||
loop through workbooks | Excel Programming | |||
Can I have a loop to open a set of workbooks get some data, close it one a time. | Excel Programming |