'An example for moving border between controls on Userform ' for Excel 97 and later 'Insert a new module, copy the following code and paste to the module. 'Run the "MakeForm" macro. Option Explicit Sub MakeForm() Dim oVBComponent As Object Dim s As String s = "Private bCaptured As Boolean" & vbCrLf s = s & vbCrLf s = s & "Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)" & vbCrLf s = s & " bCaptured = True" & vbCrLf s = s & " Image1.BackStyle = fmBackStyleOpaque" & vbCrLf s = s & " Image1.BackColor = Image1.BackColor" & vbCrLf s = s & "End Sub" & vbCrLf s = s & vbCrLf s = s & "Private Sub Image1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)" & vbCrLf s = s & " bCaptured = False" & vbCrLf s = s & " Image1.BackStyle = fmBackStyleTransparent" & vbCrLf s = s & " Image1.BackColor = Image1.BackColor" & vbCrLf s = s & "End Sub" & vbCrLf s = s & vbCrLf s = s & "Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)" & vbCrLf s = s & vbCrLf s = s & " If Not bCaptured Then Exit Sub" & vbCrLf s = s & vbCrLf s = s & " If ListBox1.Height + Y < 6 Then Exit Sub" & vbCrLf s = s & " If ListBox3.Height - Y < 6 Then Exit Sub" & vbCrLf s = s & vbCrLf s = s & " ListBox1.Height = ListBox1.Height + Y" & vbCrLf s = s & " Image2.Height = Image2.Height + Y" & vbCrLf s = s & " ListBox2.Height = ListBox2.Height + Y" & vbCrLf s = s & " Image1.Top = Image1.Top + Y" & vbCrLf s = s & " ListBox3.Top = ListBox3.Top + Y" & vbCrLf s = s & " ListBox3.Height = ListBox3.Height - Y" & vbCrLf s = s & "End Sub" & vbCrLf s = s & vbCrLf s = s & "Private Sub Image2_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)" & vbCrLf s = s & " bCaptured = True" & vbCrLf s = s & " Image2.BackStyle = fmBackStyleOpaque" & vbCrLf s = s & " Image2.BackColor = Image2.BackColor" & vbCrLf s = s & "End Sub" & vbCrLf s = s & vbCrLf s = s & "Private Sub Image2_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)" & vbCrLf s = s & " bCaptured = False" & vbCrLf s = s & " Image2.BackStyle = fmBackStyleTransparent" & vbCrLf s = s & " Image2.BackColor = Image2.BackColor" & vbCrLf s = s & "End Sub" & vbCrLf s = s & vbCrLf s = s & "Private Sub Image2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)" & vbCrLf s = s & vbCrLf s = s & " If Not bCaptured Then Exit Sub" & vbCrLf s = s & vbCrLf s = s & " If ListBox1.Width + X < 6 Then Exit Sub" & vbCrLf s = s & " If ListBox2.Width - X < 6 Then Exit Sub" & vbCrLf s = s & vbCrLf s = s & " ListBox1.Width = ListBox1.Width + X" & vbCrLf s = s & " Image2.Left = Image2.Left + X" & vbCrLf s = s & " ListBox2.Left = ListBox2.Left + X" & vbCrLf s = s & " ListBox2.Width = ListBox2.Width - X" & vbCrLf s = s & "End Sub" Set oVBComponent = ThisWorkbook.VBProject.VBComponents.Add(3) oVBComponent.Properties("Caption") = "Sample of moving border" With oVBComponent.Designer.Controls With .Add("Forms.Label.1", "Label1", True) .Left = 6 .Top = 3 .Width = 225 .Height = 15 .Caption = "Drag border between controls." End With With .Add("Forms.ListBox.1", "ListBox1", True) .Left = 6 .Top = 18 .Width = 108 .Height = 63 End With With .Add("Forms.ListBox.1", "ListBox2", True) .Left = 123 .Top = 18 .Width = 108 .Height = 63 End With With .Add("Forms.ListBox.1", "ListBox3", True) .Left = 6 .Top = 90 .Width = 225 .Height = 63 End With With .Add("Forms.Image.1", "Image2", True) .Left = 117 .Top = 18 .Width = 3 .Height = 63 .BackStyle = fmBackStyleTransparent .BackColor = &H80000010 .BorderStyle = fmBorderStyleNone .MousePointer = fmMousePointerSizeWE End With With .Add("Forms.Image.1", "Image1", True) .Left = 6 .Top = 84 .Width = 225 .Height = 3 .BackStyle = fmBackStyleTransparent .BackColor = &H80000010 .BorderStyle = fmBorderStyleNone .MousePointer = fmMousePointerSizeNS End With End With oVBComponent.CodeModule.AddFromString s VBA.UserForms.Add(oVBComponent.Name).Show End Sub