在excel-vba中调整button的大小

我有一个macros,执行一些function,并正常工作,但buttonresize的两种情况之一。 当macros使用一个自动filter(大约删除500行数据(button变得更大))时,这些button会进行重新调整,而且在我运行程序(再次变大)之前首先粘贴数据时,它们也会resize。 我试图进入属性,并select“不要移动或与细胞大小”的对象定位。 我也尝试lockingbutton的长宽比。 但是也没有保持button的大小。 任何想法,我还可以尝试什么?

我认为这应该做的伎俩。

我之前见过的另一件事是,如果button更改,字体大小有时会改变。 我包括这个,但留下它注释掉。 您可能还需要重置button的.TopLeftCell位置,该位置也包含在内,但在以下代码中注释掉了:

 '## Add the following to your existing macro: Dim btn As Shape Dim btLeft As Double, btTop As Double, btWidth As Double, _ btHeight As Double, btFontSize As Double Dim btCell As Range '## Put this block of code before your existing code: Set btn = ActiveSheet.Shapes("Button 3") '## Modify to your button name With btn btLeft = .Left btTop = .Top btHeight = .Height btWidth = .Width 'btFontSize = TextFrame2.TextRange.Font.Size 'Set btCell = btn.TopLeftCell End With 'Your code goes here: ' ' ' 'End of your code '## Put this block of code before the Exit Sub statement/after your existing code With btn '.TopLeftCell = btCell '.TextFrame2.TextRange.Font.Size = btnFontSize .Left = btLeft .Top = btTop .Height = btHeight .Width = btWidth End With