宏调用的按钮替代 - 现有按钮无法锚定。 [英] Button Alternative for Macro Call - Existing Buttons can not be anchored.

查看:88
本文介绍了宏调用的按钮替代 - 现有按钮无法锚定。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我创建了一个项目报告系统,该系统涉及最终用户,可以使用按钮将行插入表单。  我自动填充标准报告的某些部分,这意味着该按钮永远不会在每周
的相同位置,无论我尝试哪种控制属性,按钮仍会移动。


这是我当前的代码,它使用按钮地址绕过我不想复制的标题中的一些颜色设置,所以我在这个按钮的正下方有一个空行,以使格式正确。


Dim r As Range

    Dim rown As Integer

    

    Application.ScreenUpdating = False

   设置r = ActiveSheet.Buttons(Application.Caller).BottomRightCell.Offset(2).EntireRow

    r.Insert Shift:= xlDown,CopyOrigin:= xlFormatFromLeftOrAbove

    

    rown = ActiveSheet.Buttons(Application.Caller).BottomRightCell.Offset(2).Row

    

   范围("C"& rown&":R& rown)。选择

    Selection.Merge True

   范围("S"& rown&":T"& rown)。选择

    Selection.Merge True

   范围("C"& rown&":T"& rown)。选择

    Selection.Borders(xlDiagonalDown).LineStyle = xlNone

    Selection.Borders(xlDiagonalUp).LineStyle = xlNone

   使用Selection.Borders(xlEdgeLeft)

        .LineStyle = xlContinuous

        .ThemeColor = 1

        .TintAndShade = -0.499984740745262

        .Weight = xlThin

   结束使用


我找到了一个替代方法,使用复制图片命令进入单元格但操作上面的代码,如何找到单元格的地址并使用它在我上面的范围内。


另外还有一种更好的方法,因为遇到这种情况的用户数量变得沮丧,我不想重置他们的位置。



谢谢


Sean




解决方案

你可能最好开发一个插件(.xlam)。 创建一个包含按钮的表单。 这种方法的好处是您的代码和电子表格是独立的。 我从未使用VBA代码开发用户电子表格。 维持
太难了。 

Hi all

I have created a project reporting system which involved the end user, being able to insert rows into a form using a button.  I auto populate some sections of the standard report which means that the button, is never in the same place from week to week and no matter which control property I try, the buttons still move.

This is my current code which uses the button address to bypass some colour settings in the header which I dont want to duplicate so I have a blank row directly below this button to make the formatting correct.

Dim r As Range
    Dim rown As Integer
    
    Application.ScreenUpdating = False
    Set r = ActiveSheet.Buttons(Application.Caller).BottomRightCell.Offset(2).EntireRow
    r.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    
    rown = ActiveSheet.Buttons(Application.Caller).BottomRightCell.Offset(2).Row
    
    Range("C" & rown & ":R" & rown).Select
    Selection.Merge True
    Range("S" & rown & ":T" & rown).Select
    Selection.Merge True
    Range("C" & rown & ":T" & rown).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ThemeColor = 1
        .TintAndShade = -0.499984740745262
        .Weight = xlThin
    End With

I have found an alternative using a copy picture command into a cell however manipulating the code above, how do I find the address of the cell and use it in my range above.

Alternatively is there a better way as the number of users who are experiencing this are becoming frustrated and I am sick of resetting their position.



Thanks

Sean


解决方案

You may be better off developing an addin (.xlam).  Create a form that has the buttons.  The benefit of this approach is your code and spreadsheet are independent.  I never develop a user spreadsheet with VBA code.  It is too difficult to maintain. 


这篇关于宏调用的按钮替代 - 现有按钮无法锚定。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆