我最近发现了一些代码,它们在每个选定单元格的内容的左侧添加了前缀或文本。
示例:
1 -> pre.1
2 -> pre.2
6 -> pre.6
7 -> pre.7
然而,出于某种原因,代码在我选择的列的中途停止运行。例如,我想为1,000个单元格添加前缀,但代码在300左右后停止。有谁知道问题可能是什么?
干杯,非常感谢你的帮助!
代码:
Sub AddTextOnLeft()
'Updateby20131128
Dim Rng As Range
Dim WorkRng As Range
Dim addStr As String
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
addStr = Application.InputBox("Add text", xTitleId, "", Type:=2)
For Each Rng In WorkRng
Rng.Value = addStr & Rng.Value
Next
End Sub