excel - VBA-Excel 文本到数字格式问题 - 用错误的值覆盖
问题描述
我有一个代码,可以将选定单元格中的文本字符串转换为值。它工作得很好,直到选择中有一些隐藏的行。然后隐藏行下方的值将被上述单元格中的值覆盖。
您对如何修复以下代码有任何想法吗?
Sub text_to_values()
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
With Selection.SpecialCells(xlCellTypeVisible)
.NumberFormat = "General"
.Value = .Value
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
Selection.NumberFormat = "0"
End Sub
解决方案
换成这个...
For each cll in Selection.SpecialCells(xlCellTypeVisible)
cll.NumberFormat = “General”
cll.Value = cll.Value
Next cll
推荐阅读
- node.js - 获取请求适用于邮递员,但适用于浏览器
- node.js - 当主服务器关闭时,MongoDB NodeJS 客户端与副本集的连接不会重新连接
- node.js - 如何使用分子独立运行 docker 图像而不是使用“组合”?
- r - 在小鼠中进行后处理,用另一个变量替换一个变量
- html - 如何将关闭图标添加到 bootstrap 5 移动菜单?
- sql - 在上一行内的相同计算值上创建计算值
- mongoose - 尝试在 NestJS 项目中使用 Mongoose 时不断收到相同的错误
- python - Python十进制数
- wordpress - 从 URL 中删除/隐藏子目录
- javascript - NullInjectorError:没有 GoogleAnalyticsService 的提供者 - 已修复