热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何使用一个旋转按钮更改任意数量的单元格的值?-Howtochangevaluesforanynumberofcellswithonespinbutton?

ThereareanynumberofcellscontainingformulaslikeSUM(A1;A2),,SUM(N1;N2).有任意数量的单元格包含公式,如

There are any number of cells containing formulas like =SUM(A1;A2),..., =SUM(N1;N2).

有任意数量的单元格包含公式,如= SUM(A1; A2),...,= SUM(N1; N2)。

Now I want one spin button which changes all formulas at once into =Sum(A1;A2;A3),...,=SUM(N1;N2;N3).

现在我想要一个旋转按钮,它将所有公式一次改变为= Sum(A1; A2; A3),...,= SUM(N1; N2; N3)。

There are 12 different forumlas for each cell.

每个细胞有12个不同的论坛。

"Of course" my formulas are quite more complex which is why the solution should be as abstract as possible and not be taylored to solve exactly this sum-forumla-problem...

“当然”我的公式非常复杂,这就是为什么解决方案应该尽可能抽象,而不是为了解决这个总和论坛问题...

Maybe this is possible via a combination of spin button and dropdown lists containing my different formulas? I have no clue of Excel :(

也许这可以通过旋转按钮和包含我不同公式的下拉列表的组合来实现?我不知道Excel :(

How is this done? (I don't know VBA unfortunately)

这是怎么做到的? (不幸的是我不知道VBA)

Thanks for any help :-)

谢谢你的帮助 :-)

1 个解决方案

#1


0  

if your ranges are likely in sequence then you can use the following Function in VBA Editor and save the file as Excel Macro Enabled Workbook in Office-2007-onward versions:

如果您的范围可能是顺序的,那么您可以在VBA编辑器中使用以下功能并将文件保存为Office-2007-sinceward版本中的Excel Macro Enabled Workbook:

Function AutoRange(rngFrom As Range, rngTo As Integer)
    Dim a As Integer
    Dim r As Range
    Dim cell1, cell2, Rng As Range

    Set cell1 = Cells(rngFrom.Row, rngFrom.Column)
    Set cell2 = Cells(rngFrom.Row + rngTo - 1, rngFrom.Column)
    Set Rng = Range(cell1, cell2)

        For Each r In Rng
            a = a + r
        Next
    AutoRange = a
End Function

The function can be used in the format given in following image, i just used 4 cells range here:

该功能可以使用下图中给出的格式,我这里只使用4个单元格范围:

enter image description here

You just have to change green specified Cell value i.e. how much cells are in your Range in sequence downward. If it does not recalculate on changing green cell's value, just press Ctrl+Alt+F9. Just try it, thanks...

您只需更改绿色指定的单元格值,即向下按顺序在您的Range中有多少单元格。如果在更改绿色单元格的值时没有重新计算,只需按Ctrl + Alt + F9即可。试试吧,谢谢......


推荐阅读
author-avatar
春_来_茶_馆5
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有