用于按列冻结窗格的 Vba 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22326807/
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
Vba code to freeze panes columnwise
提问by Vinod Chelladurai
Can anyone please suggest the syntax for freezing panes columns wise in excel VBA. I mean I have from column A to Z. I want to freeze columns A to D so that i can scroll columns E to Z freely . I tried some code in internet but no luck.
任何人都可以建议在excel VBA中明智地冻结窗格列的语法。我的意思是我从 A 列到 Z 列。我想冻结 A 列到 D 列,以便我可以自由地将列 E 滚动到 Z 列。我在互联网上尝试了一些代码,但没有运气。
thanks in advance
提前致谢
回答by user1759942
normally I'd say that this would be the job of a paid consultant.. this one took all of 2 mins and 1 google search so here:
通常我会说这将是付费顾问的工作..这个工作花了 2 分钟和 1 次谷歌搜索,所以在这里:
Sub Macro()
With ActiveWindow
.SplitColumn = 4
.SplitRow = 0
End With
ActiveWindow.FreezePanes = True
End Sub
That will use Excels "Freeze Panes" feature to freeze columns a - d. keep in mind, that just means that columns a - d will always be visible, this does not affect rows, so when scrolling down all rows will scroll together.
这将使用 Excel 的“冻结窗格”功能来冻结 a - d 列。请记住,这仅意味着 a - d 列将始终可见,这不会影响行,因此向下滚动时所有行将一起滚动。
Please keep in mind that stackoverflow is for programing "help" and in most cases people will not code macros for you, they will help you when you are stuck in a macro. I just recorded this macro and changed one thing.
请记住,stackoverflow 用于编程“帮助”,在大多数情况下,人们不会为您编写宏,当您陷入宏时,他们会帮助您。我刚刚录制了这个宏并改变了一件事。