Sub TestUserform() ' Auteur RyuAutodidacte | 26-27/09/2023
Dim UfC, Cel As String
Cel = "F4" ' Mettre l'adresse de la cellule voulue
UfC = UserformOnCell(Cel)
With UserForm1
.Show 0 ' Show tjs à mettre avant le Left et Top
.Left = UfC(0)
.Top = UfC(1)
End With
End Sub
Function UserformOnCell(Cel As String) As Variant ' Auteur RyuAutodidacte | 26-27/09/2023
Dim Adr, CheckCol As Integer, PtToPx, PtSpxY, CmdBRib, Z, L, T
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 = 1
ActiveWindow.ScrollColumn = 1
End If
CheckCol = Range(Adr(0)).Column
If CheckCol <= Range(Cel).Column Then
ActiveWindow.ScrollColumn = CheckCol
CheckCol = Range(Cel).Column - CheckCol + 1
Else
CheckCol = Range(Cel).Column
End If
PtToPx = 0.75
PtSpxY = ActiveWindow.Panes(1).PointsToScreenPixelsY(0) * PtToPx
CmdBRib = CommandBars("ribbon").Height
With ActiveWindow
Z = .Zoom / 100
L = (.Left + Cells(Range(Cel).Row, CheckCol).Left + 21) * Z - ((.Left - 1) * (Z - 1))
T = PtSpxY + (Range(Cel).Top * Z) + CmdBRib / 4
End With
UserformOnCell = Array(L, T)
End Function