简体   繁体   English

Clean&Trim Cell VBA返回#Value

[英]Clean & Trim Cell VBA returning #Value

I have been using the below code on a workbook to clean up cells which contain a lot of text. 我一直在工作簿上使用以下代码来清理包含大量文本的单元格。 It has worked well until recently when the content in a single cell increased significantly. 直到最近,当单个单元格中的内容显着增加时,它一直运行良好。 In turn, instead of removing the excess spaces it instead changes the content of the cell to #value. 反过来,不是删除多余的空格,而是将单元格的内容更改为#value。 This only happens in cells with a lot of content. 这仅在内容很多的单元格中发生。

I was wondering if anyone could help shed some light on why this might be happening? 我想知道是否有人可以帮助阐明为什么会发生这种情况? I haven't been able to resolve it. 我无法解决。

Dim rng As Range
Dim Area As Range
Dim msg As String

'Selects range to be trimmed
Set rng = ActiveSheet.Range("B14:B2500,D14:E2500,G14:K2500")

'Trim and Clean cell values
For Each Area In rng.Areas
Area.Value = Evaluate("IF(ROW(" & Area.Address & "),CLEAN(TRIM(" & Area.Address & ")))")
Next Area

MsgBox ("Complete")
End Sub

Many Thanks 非常感谢

I recently had the same problem with this formula. 我最近对此公式也遇到了同样的问题。 When I reviewed the options for formulas for that workbook R1C1 reference style was checked. 当我查看该工作簿的公式选项时,已选中R1C1参考样式。 I unchecked it and the formula works. 我未选中它,该公式起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM