LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Cross referencing two workbooks?

Hi Everyone,

Is anyone out there that can help me. I have two workbooks. The first
workbook is open and the second workbook is close. The first workbook
contains my product code and the cost. the second workbook contains
my product code with the MOST up to date cost. I manage to create a
macro which returns the MOST up to date cost in my first workbook. But
my code is opening the second workbook. I wonder if there is a way
that i dont have to open the second workbook but still manage to do
the cross referencing?

Please advise. Below is the code.

thanks much.


Sub CostUpdate()
'
' CostUpdate Macro
' Macro recorded 13/01/2009 by jeffreyst
'

Application.ScreenUpdating = False

Dim activeWorkbookName As String

activeWorkbookName = ActiveWorkbook.Name

Workbooks.Open Filename:="G:\Commercial Auckland\Estimating Dept\Bpcs
Cost\z UpdatedCost.xls"

Dim active As Workbook

Dim sourceRow As Long
Dim destination As Long
Dim code As Long
Dim cost As Double

sourceRow = Sheets("Sheet1").Range("a65536").End(xlUp).Row
For i = 2 To sourceRow
Windows("z UpdatedCost.xls").Activate
code = Range("a" & i).Value
cost = Range("c" & i).Value

Windows(activeWorkbookName).Activate

destination = Sheets("MaterialDatabase").Range("b65536").End
(xlUp).Row

Dim cont As Boolean
Dim count As Integer

cont = True
count = 3

Do While cont
Dim matchCode As Long
matchCode = Sheets("MaterialDatabase").Range("B" &
count).Value

If matchCode = code Then
Sheets("MaterialDatabase").Range("C" & count).Value = cost
cont = False
End If

count = count + 1
If count destination Then
cont = False
End If

Loop

Next i

Windows("z UpdatedCost.xls").Activate
'Application.CutCopyMode = False
ActiveWorkbook.Close

End Sub
 
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
cross referencing 2 workbooks at same time GezCam Excel Worksheet Functions 3 December 3rd 08 03:04 PM
Cross Referencing Saxman Excel Discussion (Misc queries) 0 October 26th 06 04:58 PM
Cross referencing sb1920alk Excel Worksheet Functions 1 October 4th 06 02:22 AM
Cross referencing data across different workbooks Luke Excel Discussion (Misc queries) 1 August 8th 06 10:19 PM
cross referencing Phil Excel Worksheet Functions 6 August 2nd 05 06:07 PM


All times are GMT +1. The time now is 06:23 PM.

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"