[英]Replace semi-colon with comma
I want to replace a semi-colon with a comma in a range. 我想用逗号替换范围内的分号。
The following code only deletes the semi-colon, it doesn't put the comma in its place. 以下代码仅删除分号,而不用逗号代替。
Range("AU2:AU250").Select
Selection.Replace What:=";", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Try this ... 尝试这个 ...
Sub Comma()
Dim R As Range, C As Range
Set R = Range([AU2], [AU250])
For Each C In R.Cells
C = Replace(C, ";", ",")
Next C
End Sub
This is IMHO a more VBA like approach making use of range objects rather than simulating Excel stuff that you would use when interacting directly with your sheet 这是恕我直言,一种更像VBA的方法,它利用范围对象而不是模拟直接与工作表交互时将使用的Excel内容
Can you copy paste some of the offending cells from the CSV range in the csv file? 您可以复制csv文件中CSV范围内的某些有问题的单元格吗? Open it in wordpad though, not in excel. 虽然在写字板中打开它,而不是在excel中打开它。
Also, what version of excel are you using? 另外,您使用的是哪个版本的excel? I haven't managed to get this to occur either on 2003 or 2010. 我没有设法使这种情况发生在2003年或2010年。
And I assume you need to do this more than once is why you are making a macro or is find/replace failing and you are posting macro code to get help with that too? 而且我认为您需要多次执行此操作,这就是为什么要创建宏或查找/替换失败并且您正在发布宏代码以获取帮助的原因吗? :-) :-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.