I did it similar to Aflatoon's code but with some assumptions.
In a Module:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
'API's for getting the factors to convert points to pixels
Private Declare Function GetDC Lib "user32" ( _
ByVal hwnd As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" ( _
ByVal hdc As Long, _
ByVal nIndex As Long) As Long
Private Declare Function ReleaseDC Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hdc As Long) As Long
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const LOGPIXELSY = 90
'The width of a Y pixel in Excel's userform coordinates
Public Function PointsPerPixelY() As Double
Dim hdc As Long
hdc = GetDC(0)
PointsPerPixelY = 72 / GetDeviceCaps(hdc, LOGPIXELSY)
ReleaseDC 0, hdc
End Function
Function RectVScrollBar() As RECT
Dim xlmain As Long, xldesk As Long, excel As Long
Dim nuiscrollbar As Long, netuihwnd As Long
xlmain = FindWindow("xlmain", vbNullString)
xldesk = FindWindowEx(xlmain, 0&, "xldesk", vbNullString)
excel = FindWindowEx(xldesk, 0&, "excel7", vbNullString)
nuiscrollbar = FindWindowEx(excel, 0&, "nuiscrollbar", vbNullString)
netuihwnd = FindWindowEx(nuiscrollbar, 0&, "netuihwnd", vbNullString)
Dim TheRect As RECT
' size and position values stored in rect
GetWindowRect netuihwnd, TheRect
RectVScrollBar = TheRect
End Function
Function HBar() As RECT
Dim xlmain As Long, excelh As Long
xlmain = FindWindow("xlmain", vbNullString)
excelh = FindWindowEx(xlmain, 0&, "excelh", vbNullString)
Dim TheRect As RECT
' size and position values stored in rect
GetWindowRect excelh, TheRect
HBar = TheRect
End Function
In the Userform2 or change the name Userform2 to your Userform's name:
Private Sub UserForm_Activate()
Dim vsbar As RECT
vsbar = RectVScrollBar
With UserForm2
.Left = vsbar.Left * PointsPerPixelY - .Width
.Top = HBar.Bottom * PointsPerPixelY
End With
End Sub