When you display a user form modally,
UserForm1.Show vbModal ' =1
the code shows the form and then pauses execution on that line and
will not continue execution until the form is hidden or unloaded.
While the form is visible, the user can have no interaction with the
worksheet. Only controls on the user form can be used.
When you display a form modelessly,
UserForm1.Show vbModeless ' =0
the form is displayed but code execution continues on to whatever
follows the Show method. (I would get in the habit of using the
constant names vbModal and vbModeless rather than the numeric
equivelants of 1 and 0. It makes reading the code easier.) When a
modeless form is visible, the user has full access to all elements of
the worksheet.
There really isn't any way to individually enable or disable specific
elements of the Excel UI.
If all you want to do is allow the user to scroll around the worksheet
without any other interaction, put two scroll bars on the user form,
one oriented vertically and name it VScroll. The other scroll bar
should be oriented horizontally and named HScroll. Then, in your
userform's code, use
Private Sub UserForm_Initialize()
Me.VScroll.Min = 1
Me.VScroll.Max = 1000
Me.HScroll.Min = 1
Me.HScroll.Max = 100
End Sub
Private Sub HScroll_Change()
Static PrevCol As Long
Dim N As Long
If PrevCol = 0 Then
PrevCol = ActiveWindow.VisibleRange.Cells(1, 1).Column
End If
N = Me.HScroll.Value - PrevCol
ActiveWindow.SmallScroll toright:=N
PrevCol = ActiveWindow.VisibleRange.Cells(1, 1).Column
End Sub
Private Sub VScroll_Change()
Static PrevRow As Long
Dim N As Long
If PrevRow = 0 Then
PrevRow = ActiveWindow.VisibleRange.Cells(1, 1).Row
End If
N = Me.VScroll.Value - PrevRow
ActiveWindow.SmallScroll down:=N
PrevRow = ActiveWindow.VisibleRange.Cells(1, 1).Row
End Sub
Then, show the form modally:
UserForm1.Show vbModal
While the form is displayed, the user can use the scroll bars on the
user form to move about the worksheet. He won't have access to the
worksheet's scrollbars, but the scrollbars on the user form will mimic
the behavior of the worksheet's scrollbars well enough to serve the
purpose.
I can't think of any other way to display a modal form and still allow
interaction of any sort with the worksheet while the form is visible.
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)