vba 垂直滚动不起作用。电子表格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10897824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 16:22:19  来源:igfitidea点击:

Vertical Scroll not working. Excel

excelexcel-vbavba

提问by Matt Ridge

I have an excel sheet that I am attempting to have a scroll bar show only 10 of the possible hundreds of items on a list. I created a scroll bar, had it reference a field, for calculations. Each field that the scroll bar interacts with is referenced off the field as well. So I can't imagine why it's not working.

我有一个 excel 表,我试图让滚动条仅显示列表中可能的数百个项目中的 10 个。我创建了一个滚动条,让它引用一个字段,用于计算。滚动条与之交互的每个字段也在该字段外引用。所以我无法想象为什么它不起作用。

What is happening is that when I scroll the bar up and down the text to the right of it doesn't move. I'd like to know if it is my computer, or not. If it is my computer what would I need to do to make it work? I use VBA and I may of accidently disabled something to allow the scrolling to not work, but I don't know.

发生的事情是,当我上下滚动栏时,它右侧的文本不会移动。我想知道是不是我的电脑 如果是我的电脑,我需要做什么才能让它工作?我使用 VBA,我可能不小心禁用了某些东西以使滚动不起作用,但我不知道。

Can someone help please?

有人可以帮忙吗?

Here is the worksheet in question.

这是有问题的工作表。

https://dl.dropbox.com/u/3327208/Excel/scrollnotworking.xlsx

https://dl.dropbox.com/u/3327208/Excel/scrollnotworking.xlsx

回答by Siddharth Rout

Your calculation is set to Manual.

您的计算设置为手动。

Do this. Under the

做这个。在下面

Formulas Tabclick on Calculation Optionsand then on Automatic

Formulas Tab点击Calculation Options然后点击Automatic

Now try it

现在试试

enter image description here

在此处输入图片说明

FOLLOWUP

跟进

sweet perfect, is there a way in VBA to make this happen? I have to go through my code and find out if there is a spot where makes this as Manual... because I think there is. – Matt Ridge 1 min ago

甜蜜完美,VBA 中有没有办法实现这一点?我必须仔细检查我的代码,看看是否有一个地方可以把它作为手册......因为我认为有。– 马特里奇 1 分钟前

There are mainly two reasons why the calculation switches to manual via VBA

通过VBA计算切换到手动主要有两个原因

1)You set it MANUALand then forget to set it back. For example

1)您设置了它MANUAL,然后忘记将其设置回来。例如

Sub Sample()
    Application.Calculation = xlCalculationManual

    '~~> Rest of your code
End Sub

2)You set it to MANUALin the beginning and set it AUTOMATICin the end but it still remains MANUAL. This primarily happens because you didn't include proper Error Handlingbecause of which the code exits prematurely from the procedure. See this example

2)您将其设置MANUAL为开头并设置AUTOMATIC为结尾,但它仍然存在MANUAL。这主要是因为您没有包含正确Error Handling的代码,因此代码过早地从过程中退出。看这个例子

The wrong way

错误的方法

Sub Sample()
    Application.Calculation = xlCalculationManual

    '~~> Rest of your code

    Application.Calculation = xlCalculationAutomatic
End Sub

The preferred way

首选方式

Sub Sample()
    On Error GoTo Whoa

    Application.Calculation = xlCalculationManual

    '~~> Rest of your code

Letscontinue:
    Application.Calculation = xlCalculationAutomatic
    Exit Sub
Whoa:
    MsgBox Err.Description
    Resume Letscontinue
End Sub

Note: If you want, You can also store the current state of Calculationand set it back at the end of the code if you want to.

注意:如果需要,您还可以存储当前状态Calculation并将其设置回代码末尾。