Function getSmallNumb() As Integer
Dim tx As Variant
Dim Tobj As Object
Set Tobj = ActiveSheet.OLEObjects(\"TextBox1\").Object
tx = VBA.Trim(Tobj.Value)
If Not VBA.IsNumeric(tx) Then
getSmallNumb = 0
Else
getSmallNumb = tx
End If
End Function
由于做了一个自定义滚动行数,所以在获取滚动行数时要进行处理。
实际应用中,这个功能还是有很大的自由度的。
按钮代码
Private Sub CommandButton1_Click()
ActiveWindow.SmallScroll down:=getSmallNumb'向下滚动
setLabelCaption (Me.CommandButton1.Caption)
End Sub
Private Sub CommandButton2_Click()
ActiveWindow.SmallScroll up:=getSmallNumb’向上滚动
setLabelCaption (Me.CommandButton2.Caption)
End Sub