vba 如何重置 Excel 垂直滚动条长度(不关闭,然后重新打开工作簿)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24099690/
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
How to reset Excel Vertical Scroll Bar length (without closing, then re-opening Workbook)
提问by Brian Mustang
Part of my program pastes several columns of data in a worksheet, then removes duplicate values in each column (with the variable range to search for duplicate values called rngDelete), then counts the number of unique values. After getting the count values, I delete all the rows in rngDelete.
我的程序的一部分将几列数据粘贴到工作表中,然后删除每列中的重复值(使用变量范围来搜索称为 rngDelete 的重复值),然后计算唯一值的数量。获得计数值后,我删除了 rngDelete 中的所有行。
But I notice that after deleting the rows, my vertical scroll bar length still remains the same, i.e. the same length as when I had data in rngDelete rows. It is true that re-opening the worksheet will reset the scroll bar length, but I was wondering if there is a way to force this to happen upon program runtime completion?
但我注意到删除行后,我的垂直滚动条长度仍然保持不变,即与我在 rngDelete 行中有数据时的长度相同。重新打开工作表确实会重置滚动条长度,但我想知道是否有办法在程序运行时完成时强制执行此操作?
回答by dcromley
Excuting the following resets the lastcell and does what you want.
执行以下操作将重置 lastcell 并执行您想要的操作。
ActiveSheet.UsedRange.SpecialCells (xlCellTypeLastCell)