Sub TestUserform() ' Auteur RyuAutodidacte - Version 2.1 | 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, 3)
With UserForm1
.startupposition = 0
.Left = UfC(0)
.Top = UfC(1)
.Show 0
End With
End Sub
Function UserformOnCell(cel As String, getPane As Byte) As Variant ' Auteur RyuAutodidacte - Version 2.1 | 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
L = .Panes(getPane).PointsToScreenPixelsX(Range(cel).Left) - MargeLeft
T = .Panes(getPane).PointsToScreenPixelsY(Range(cel).Top) - MargeTop
End With
UserformOnCell = Array(L, T)
End Function