即时寻找我的项目的解决方案。我有源数据workbook_src
和目标worbook_dest
。在workbook_src
在格式上="123456789"
数字。我的目标是开放workbook_src
为只读,用数字拷贝行记忆,他们明确的只数并粘贴特workbook_dest
的价值。
打开workbook_src
为只读
Dim src As Workbook
Set src = Workbooks.Open("C:\xxx.xlsx", True, True)
ThisWorkbook.Activate
功能清晰数字
Function GetNumeric(CellRef As String)
Dim StringLength As Integer
StringLength = Len(CellRef)
For i = 1 To StringLength
If IsNumeric(Mid(CellRef, i, 1)) Then Result = Result & Mid(CellRef, i, 1)
Next i
GetNumeric = Result
End Function
但我有问题得到这个功能applicated上整排
找到解决方案
Function cleanString(str As String) As String
Dim ch, bytes() As Byte: bytes = str
For Each ch In bytes
If Chr(ch) Like "[A-Z.a-z 0-9]" Then cleanString = cleanString & Chr(ch)
Next ch
End Function
Sub btn_CleanAll()
Dim rng As Range
For Each rng In Sheets("Sheet1").Range("A2:A30000").Cells
rng.Value = cleanString(rng.Value)
Next
MsgBox "Done"
End Sub