I have a UserForm MonthView and DTPicker that will populate when certain cells are clicked. I have a form located directly below the first cell, but I would like it to be filled right below each active cell, and I tell her to activate it. My current activation code for posting a custom form:
Private Sub UserForm_Activate() With frmCalendar .Top = Application.Top + 340 .Left = Application.Left + 330 End With End Sub
and my code for selecting a worksheet that will launch a custom form with certain clicks on the cell will be:
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range("H10,H15")) Is Nothing Then frmCalendar.Show End If End Sub
I know that there are add-ons that help to do this, but I would like to figure out how to place the user form directly under the above cells (H10, H14, H15) without using an add-in. Do I need to add code to the worksheet or activate sub? What code will be?
Thanks.
EDIT:
I just changed Activate Sub Code to
Private Sub UserForm_Activate() With frmCalendar .Top = ActiveCell.offset(31).Top .Left = ActiveCell.offset(1).Left End With
End Sub
This moves it slightly lower and slightly to the right of the cell, but when I try to use it in another cell, it moves further down, but remains at the same distance to the right. It is still dirty. Can't place this form directly under ActiveCell using these methods?
vba excel-vba excel position cell
Sinister swan
source share