Here's one way: set up three matching arrays:
myGroup contains the userform controls in your group as objects.
leftOffset and
topOffset hold the offsets from the first controls.
By passing the new location of the control myGroup(0) to the sub Move, all the controls in myGroup will move as a block.
This could also be done with a 3Xn array.
Dim myGroup As Variant
Dim leftOffset() As Long
Dim topOffset() As Long
Sub setUp()
Dim i As Integer, newTop As Integer, newLeft As Integer
With UserForm1
myGroup = Array(.TextBox1, .TextBox1, .ListBox1, .ListBox2)
End With
For i = 0 To UBound(myGroup)
leftOffset(i) = myGroup(i).Left - myGroup(0).Left
topOffset(i) = myGroup(i).Top - mygoup(0).Top
Next i
End Sub
Sub moveGroup(newLeft As Integer, newTop As Integer)
Dim i As Integer
For i = 0 To UBound(myGroup)
myGroup(i).Left = newLeft + leftOffset(i)
myGroup(i).Top = newTop + topOffset(i)
Next i
End Sub
Bookmarks