Hi, Joshi,
having thought about it a bit longer I may categorize 3 different situations.
First:
working on both files on the same computer in the same instance. Hardly a challenge as the following codes may be used:
Private Sub Worksheet_Change(ByVal Target As Range)
'behind WP_Tracker
Dim wkb As Workbook
Dim wks As Worksheet
Dim rngFound As Range
If Target.Count > 1 Then Exit Sub
If Target.Row > 1 And Target.Column < 18 Then
On Error Resume Next
Set wkb = Workbooks.Open(ThisWorkbook.Path & "\JobList.xlsm")
On Error GoTo 0
If Not wkb Is Nothing Then
Set wks = wkb.Sheets("Justified")
Set rngFound = wks.Range("G:G").Find(what:=Cells(Target.Row, "G").Value)
If Not rngFound Is Nothing Then
Application.EnableEvents = False
wks.Range("A" & rngFound.Row & ":P" & rngFound.Row).Value = Range("A" & Target.Row & ":P" & rngFound.Row).Value
wks.Range("Q" & rngFound.Row).Value = Range("Q" & rngFound.Row).Value
Application.EnableEvents = True
End If
Set wks = Nothing
wkb.Close True
Set wkb = Nothing
End If
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
'behind Justified
Dim wkb As Workbook
Dim wks As Worksheet
Dim rngFound As Range
If Target.Count > 1 Then Exit Sub
If Target.Row > 1 And Target.Column < 17 Then
On Error Resume Next
Set wkb = Workbooks.Open(ThisWorkbook.Path & "\Workpack_Status_Tracker.xlsm")
On Error GoTo 0
If Not wkb Is Nothing Then
Set wks = wkb.Sheets("WP_Tracker")
Set rngFound = wks.Range("G:G").Find(what:=Cells(Target.Row, "G").Value)
If Not rngFound Is Nothing Then
Application.EnableEvents = False
wks.Range("A" & rngFound.Row & ":P" & rngFound.Row).Value = Range("A" & Target.Row & ":P" & rngFound.Row).Value
Range("Q" & rngFound.Row).Value = wks.Range("Q" & rngFound.Row).Value
Application.EnableEvents = True
End If
Set wks = Nothing
wkb.Close True
Set wkb = Nothing
End If
End If
End Sub
Second:
working on the file in two instances of Excel on the same computer. As no direct connection is available copying between the files could be used.
Third:
working with 2 files on two different computers. No shared workbook could be used for this as you are working with 2 different workbooks. And any VBA code will have to look if the other workbook is open and then act according to the first code or use either a textfile or a third workbook to store the data. This could be done by checking if any entry/change has been made to import the available new data.
This overhead may lead to problems if both workbooks update in the same area at about the same time. Apart from that there is a multiple storing of the same data.
That was the reason why I stated that I would have used a Database. Most of the action in Excel by programming can be done in a Database with less or hardly any programming, thus the DB having better algorithms for record locking, storage of data, security. Excel may be used as a frontend to the Database.
Ciao,
Holger
Bookmarks