1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Option Explicit
Public Function decaler_lig_col(lig As Integer, col As Integer, oRng As Range)
Dim oStr As String
Dim oWkb As Workbook
Dim oWksh As Worksheet
Dim oOri As Range
oStr = oRng.Formula
'Call OpenIfNec(oStr)
Set oWkb = Workbooks(Mid(oStr, InStr(oStr, "[") + 1, InStr(oStr, "]") - InStr(oStr, "[") - 1))
Set oWksh = oWkb.Worksheets(Mid(oStr, InStr(oStr, "]") + 1, InStr(InStr(oStr, "]"), oStr, "'") - InStr(oStr, "]") - 1))
Set oOri = oWksh.Range(Right(oStr, Len(oStr) - InStr(oStr, "!")))
decaler_lig_col = oOri.Offset(lig, col)
End Function
Sub OpenIfNec(oStr As String)
Dim nom As String
nom = Replace(Replace(Mid(oStr, 3, InStr(oStr, "]") - 2), "[", ""), "]", "")
On Error Resume Next
Workbooks(nom).Activate
If Err <> 0 Then
Workbooks.Open nom
If Err <> 0 Then
MsgBox "Le fichier " & nom & " est introuvable."
End If
End If
End Sub |
Partager