Option Explicit
Const XXX = "Pro_Omega.xls"
Sub externalkey()
'Check Path
If FileExists("X:\Resource Centres\OMEGA_Vehicle_Key_Master.xls") Then GetLatestVersionID 'working
'Get Current Value
If FileExists("X:\Resource Centres\OMEGA_Vehicle_Key_Master.xls") Then
Range("K1").Select
ActiveCell.Value = "Main"
Range("L1").Select
Selection.NumberFormat = "0.00"
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-1],'X:\Resource Centres\[OMEGA_Vehicle_Key_Master.xls]VehicleKeyMain'!R1C9:R1C10,2,0)"
Range("j5").Select
End If
'Compare Values & Update Message
If Range("L1").Value > Range("G1").Value Then message
'Import New data
'IsVehicleKeyAvailable
'*****************************
'look for updated vehicle key
End Sub
Sub message()
Select Case MsgBox("A New version of the Vehicle Key now exists" _
& vbCrLf & "You should allow this update to run" _
& vbCrLf & "" _
& vbCrLf & "INSTALL AT THIS TIME ?" _
, vbYesNo Or vbQuestion Or vbSystemModal Or vbMsgBoxRtlReading Or vbDefaultButton1, "Vehicle Key")
'Keys are reversed Yes / No
Case vbYes
' copy the new data over the old data
copynewtoold
updateversionnumber
Case vbNo
End Select
End Sub
Public Sub GetLatestVersionID()
'not used, step over
'Dim getvalue As array
'Dim P, F, S, A, KeyA
' P = "X:\Resource Centres"
' F = "OMEGA_Vehicle_Key_Master.xls"
' S = "VehicleKey"
' A = "J1"
'KeyA = getvalue(P, F, S, A)
End Sub
Public Sub copynewtoold()
Dim fPath, fName, sName, sName2, CellRange As String
Workbooks(XXX).Worksheets("VehicleKey").Visible = True
'fPath = "C:\Users\xxxx\Desktop"
fPath = "X:\Resource Centres"
fName = "OMEGA_Vehicle_Key_Master.xls"
sName = "VehicleKeyMain" 'from worksheet named
sName2 = "VehicleKey" 'to worksheet named
CellRange = "A2:I10000"
Application.DisplayAlerts = False
Workbooks.Open fPath & "\" & fName
'Workbooks.Open "C:\Users\xxxx\Desktop\OMEGA_Vehicle_Key_Master.xls"
Worksheets(sName).Range(CellRange).Copy
ActiveWorkbook.Close
Worksheets(sName2).Range(CellRange).PasteSpecial
Workbooks(XXX).Worksheets("VehicleKey").Visible = False
Application.DisplayAlerts = True
ThisWorkbook.Save
'MsgBox "Vehicle Key Updated"
End Sub
Public Sub updateversionnumber()
'On Error Resume Next
'New Value to Master Key
Dim marker As String
Sheets("VehicleKey").Visible = True
Sheets("WestCover").Select
Range("L1").Select
Selection.Copy
marker = Range("L1")
Sheets("VehicleKey").Select
Range("J1").Select
Range("J1") = marker
'ActiveCell.FormulaR1C1 = "=WestCover!RC[-3]"
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'Range("J2").Select
ActiveWindow.SelectedSheets.Visible = False
'Workbooks(XXX).Worksheets("WestCover").Select
' Range("G1").Select
' ActiveCell.FormulaR1C1 = "=VehicleKey!RC[3]"
' Range("G1").Select
' Selection.Copy
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'New Value to Display
Workbooks(XXX).Worksheets("WestCover").Select
Range("G1").Select
ActiveCell.FormulaR1C1 = "=VehicleKey!RC[3]"
Range("G1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub