LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Loop with two workbooks

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop through folder of workbooks and add rows FIRSTROUNDKO via OfficeKB.com Excel Worksheet Functions 0 August 10th 06 07:50 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM
loop through workbooks Keith Willshaw Excel Programming 2 September 19th 03 12:48 PM
loop through workbooks Ron de Bruin Excel Programming 1 September 18th 03 02:53 PM
Can I have a loop to open a set of workbooks get some data, close it one a time. wellie Excel Programming 2 July 9th 03 04:58 AM


All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"