gpt4 book ai didi

excel - 如何从单元格值启动宏

转载 作者:行者123 更新时间:2023-12-04 21:44:43 25 4
gpt4 key购买 nike

是否可以从单元格上的值启动宏?
换句话说,我想将其转换为:

Sub Batch()

'Execute les macros BatchRbk,BatchR, BatchAbk et BatchA à differentes heures
Application.OnTime TimeValue("08:33:00"), "Batch.BatchRbk"
Application.OnTime TimeValue("08:37:00"), "Batch.BatchR"
Application.OnTime TimeValue("10:29:00"), "Batch.BatchAbk"
Application.OnTime TimeValue("10:34:00"), "Batch.BatchA"
Application.OnTime TimeValue("10:39:00"), "Batch.BatchRbk"
Application.OnTime TimeValue("10:43:00"), "Batch.BatchR"
Application.OnTime TimeValue("11:29:00"), "Batch.BatchAbk"
Application.OnTime TimeValue("11:32:00"), "Batch.BatchA"
Application.OnTime TimeValue("12:29:00"), "Batch.BatchAbk"
Application.OnTime TimeValue("12:34:00"), "Batch.BatchA"
Application.OnTime TimeValue("13:29:00"), "Batch.BatchAbk"
Application.OnTime TimeValue("13:32:00"), "Batch.BatchA"
Application.OnTime TimeValue("13:39:00"), "Batch.BatchRbk"
Application.OnTime TimeValue("13:44:00"), "Batch.BatchR"
Application.OnTime TimeValue("14:14:00"), "Batch.BatchAbk"
Application.OnTime TimeValue("14:16:00"), "Batch.BatchA"
Application.OnTime TimeValue("14:30:00"), "Batch.BatchAbk"
Application.OnTime TimeValue("14:32:00"), "Batch.BatchA"
Application.OnTime TimeValue("14:40:00"), "Batch.BatchAbk"
Application.OnTime TimeValue("14:43:00"), "Batch.BatchA"

End Sub
对此:
enter image description here
我是一种用户可以设置自己的方式,即在“x”小时他想启动宏“y”。
如果有什么地方不够清楚,请告诉我,我会重新解释得更好。
谢谢 !

最佳答案

请尝试下一个方法:

  • 除了您在“D:E”列中向我们展示的数据外,您还需要另一列真实名称为 Sub。被调用(“Batch.BatchRbk”、“Batch.BatchR”等)。让我们把它放在 F:F 列中,它可能被隐藏,也可能不被隐藏。
  • 然后按照下一个方式进行:
  • Sub Batch()
    Dim ws as Worksheet,lastR as Long, i as long

    Set ws = ActiveSheet
    lastR = ws.Range("D" & ws.rows.count).End(xlup).row
    For i = 2 to lastR
    Application.OnTime TimeValue(ws.Range("D" & i).value), ws.Range("F" & i).value
    Next i
    End Sub
    在 F:F 列中,您必须放置:“Batch.BatchRbk”、“Batch.BatchR”、“Batch.BatchAbk”等等...

    关于excel - 如何从单元格值启动宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68904599/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com