vba excel 去掉单元格中隐藏着的双引号或单引号 (多列含有,希望得到一次性清楚)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vba excel 去掉单元格中隐藏着的双引号或单引号 (多列含有,希望得到一次性清楚)相关的知识,希望对你有一定的参考价值。
分列 能全部一次行处理么?
clean函数vba是否可用?
格式设置,自定义如何定义可以实现呢?
……
是否有其它更好的方法?
谢谢!
乘以1或者+0 粘贴,有的列是文字,没有意义,二是单引号又变成了双引号。
Dim rng As Range
For Each rng In UsedRange
If InStr(1, rng.Value, "'", vbTextCompare) <> 0 Or InStr(1, rng.Value, Chr(34), vbTextCompare) <> 0 Then
rng = Application.WorksheetFunction.Substitute(rng.Value, "'", "")
rng = Application.WorksheetFunction.Substitute(rng.Value, Chr(34), "")
End If
Next
End Sub追问
f8,运行到第三行中报错。
Sub mysub()
Dim rng As Range
For Each rng In sheets("sheet1")UsedRange '指定某个表格的使用区域
If InStr(1, rng.Value, "'", vbTextCompare) 0 Or InStr(1, rng.Value, Chr(34), vbTextCompare) 0 Then
rng = Application.WorksheetFunction.Substitute(rng.Value, "'", "")
rng = Application.WorksheetFunction.Substitute(rng.Value, Chr(34), "")
End If
Next
End Sub
具体操作呢?能讲一下?谢谢
追答选中待替换的区域,(ctrl+F) 查找内容 “ 稍后换成‘
替换为 为空
Excel(VBA)下拉列表单个单元格中的多个值
Selecting different values from a data validation drop down list will populate the same cell, i.e. it will create a concatenating list separated by commas.Amend the "If Target.Column" values to set the columns this applies to.
Private Sub Worksheet_Change(ByVal Target As Range) ' Developed by Contextures Inc. ' www.contextures.com Dim rngDV As Range Dim oldVal As String Dim newVal As String If Target.Count > 1 Then GoTo exitHandler On Error Resume Next Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation) On Error GoTo exitHandler If rngDV Is Nothing Then GoTo exitHandler If Intersect(Target, rngDV) Is Nothing Then 'do nothing Else Application.EnableEvents = False newVal = Target.Value Application.Undo oldVal = Target.Value Target.Value = newVal If Target.Column = 3 Then If oldVal = "" Then 'do nothing Else If newVal = "" Then 'do nothing Else Target.Value = oldVal _ & ", " & newVal ' NOTE: you can use a line break, ' instead of a comma ' Target.Value = oldVal _ ' & Chr(10) & newVal End If End If End If End If exitHandler: Application.EnableEvents = True End Sub
以上是关于vba excel 去掉单元格中隐藏着的双引号或单引号 (多列含有,希望得到一次性清楚)的主要内容,如果未能解决你的问题,请参考以下文章
CSV文件的双引号怎么去掉。用记事本打开有双引号,EXCEL打开又没有了,怎么样去掉这个双引号,这是个啥