简体   繁体   English

用逗号替换分号

[英]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.

相关问题 .csv文件中的VBA仅用3列中的分号替换逗号 - Replace comma with semi-colon in only 3 columns with VBA within .csv file 如何使用VBA保存分号分隔的csv文件? - How to save semi-colon delimited csv file using VBA? 通过单元格而不是用python分号将数据保存在excel中 - Saving data in excel by cell rather than semi-colon with python Excel数据透视表-提取数据透视表项目列表并用分号连接 - Excel Pivot Table - Extract List of Pivot Items and Concatenate with semi-colon Excel - 如何将多列中的分号分隔值拆分为行 - Excel - How to split semi-colon separated values in multiple columns into rows 使用 ';' 从文本字符串创建单个单元格列表分号分隔符 - Create Single Cell Lists from Text Strings With ';' Semi-Colon Delimiter 删除字符串的一部分(';' 分号分隔符)并在一个单元格中列出字符串的其余部分 - Remove parts of a string ( ';' Semi-Colon Delimiter) and listing the remainder of the string in one cell Excel 列包含分号分隔的多个名称,需要过滤具有多个值的行,省略单个值 - Excel column that contains semi-colon separated multiple names, need to filter rows that have multiple values, omitting single values 在输入excel掩码上用冒号替换逗号 - Replace comma with colon on input excel mask VBA 中的半冒号分隔 csv - Semi colon seperated csv in VBA
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM