Sub TestUserform() ' Auteur RyuAutodidacte - Version 2 | 26-27/09/2023-V1 | 30/09/2023-V2
Dim UfC, Cel As String
Cel = "F4" ' Mettre l'adresse de la cellule voulue
UfC = UserformOnCell(Cel)
With UserForm1
.StartUpPosition = 0
.Left = UfC(0)
.Top = UfC(1)
.Show 0
End With
End Sub
Function UserformOnCell(Cel As String) As Variant ' Auteur RyuAutodidacte - Version 2 | 26-27/09/2023 | 30/09/2023-V2
Dim Adr, Z, L, T, MargeLeft As Byte, MargeTop As Byte
MargeLeft = 2: MargeTop = 3
Adr = Split(ActiveWindow.VisibleRange.Address, ":")
If (Range(Cel).Column >= Range(Adr(0)).Column And Range(Cel).Column <= Range(Adr(1)).Column And Range(Adr(0)).Row <= Range(Cel).Row) = False Then
ActiveWindow.ScrollRow = Range(Cel).Row
ActiveWindow.ScrollColumn = Range(Cel).Column
End If
With ActiveWindow
Z = .Zoom / 100
L = .Panes(1).PointsToScreenPixelsX(0) - MargeLeft + (Range(Cel).Left * Z)
T = .Panes(1).PointsToScreenPixelsY(0) - MargeTop + (Range(Cel).Top * Z)
End With
UserformOnCell = Array(L, T)
End Function