vba - 宏没有按应有的方式划分
问题描述
我有一个可以工作的宏,但只有在除以 19.00 时才有效。当 20.00 或更高是要划分的数字时,它只划分为 10.00,仅此而已。它应该做的是将高达 12.00 的任何数字分成 10 个单元格,并且任何超过 12.00 的数字都应该将多余的数量写入找到的对中的第一个数字。
此外,我的宏最后引用了“Range("G" & found).Value = pair”,但没有写入任何内容。我真正需要的是删除它或使其灵活地写入特定的单元格,以便将来可以更改它,或者正如我所说的那样删除它。
如果有人可以看看,看看我没有看到它肯定会很感激。
Sub DIVIDE()
Application.ScreenUpdating = False
Dim pair As Variant, accumulator As Variant
Dim findFifteen As Double
Dim remainder As Long, found As Long
found = 1
For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = 15 Then
If pair.Offset(0, 1) <= 12 Then
findFifteen = pair.Offset(0, 2) / 10
remainder = 0
Else
findFifteen = 1
remainder = pair.Offset(0, 2) Mod 10
End If
For Each accumulator In Range("A36, D36, G36, J36, M36, A40, D40, G40, J40, M40")
If accumulator.Offset(-1, 0) = Val(Left(pair, InStr(pair, "-") - 1) Then
accumulator.Value = accumulator.Value + remainder
End If
accumulator.Value = accumulator.Value + findFifteen
Next accumulator
Range("G" & found).Value = pair
found = found + 1
End If
Next pair
Application.ScreenUpdating = True
End Sub
解决方案
推荐阅读
- javascript - 在反应中设置本地日期时间的动态值
- javascript - Visual Studio Code:在浏览器中打开当前 HTML 文件 (launch.json)
- rest - 集成rest api间服务调用的最佳实践?
- regex - 正则表达式 - 在最后两个“-”之间找到一个字符串
- scala - 如何使用 SBT 将 MATSim 添加到我的 Scala 项目中?
- javascript - 在javascript中将html表数据解析为JSON数组
- mapbox - 中国的 Mapbox(9 虚线)
- javascript - 播放歌曲时不显示播放按钮
- html - 创建从 HTML 到 JQUERY 的点击事件
- xml - 如何使用 xslt 转换 xml?