代碼的重點是轉換.成,
它是在 csv 資料上完成的,太大而無法手動完成
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
Sub Transformer_Point_To_Virgule()
i = 0
b = 0
Do While b = 0
If UCase(ActiveCell.Value) Like "*.*" Then
Sleep 300
ActiveCell.NumberFormat = "General"
y = ActiveCell.Value
x = Split(y, ".")
Z = x(0) & "," & x(1)
MsgBox x(0) & " " & x(1) & Chr(10) & Z
ActiveCell.Value = Z
Do While UCase(ActiveCell.Value) <> Z
ActiveCell.NumberFormat = "General"
MsgBox Z
ActiveCell.Value = Z
Loop
End If
ActiveCell.Offset(0, 1).Select
i = i 1
If ActiveCell = "" Then
ActiveCell.Offset(1, -i).Select
i = 0
End If
If ActiveCell = "" Then
b = 1
End If
Loop
問題有時不是放:
x(0) & "," & x(1)作為單元格值,它只放x(0) & x(1)不帶,,這會給出非常不正確的結果
我就是不明白為什么='(
uj5u.com熱心網友回復:
您的解決方案看起來過于復雜。您只需要將任何數字單元格替換為實數.即可,。Application.DecimalSeparator
Option Explicit
Public Sub Example()
ConvertIntoNumber ActiveSheet.Range("A1:B7")
End Sub
Public Sub ConvertIntoNumber(ByVal ConvertRange As Range)
Dim Cell As Range
For Each Cell In ConvertRange
If IsNumeric(Cell.Value2) Then
Cell.Value2 = CDbl(Replace(Cell.Value2, ".", Application.DecimalSeparator))
Cell.Value2 = CDbl(Replace(Cell.Value2, ",", Application.DecimalSeparator))
End If
Next Cell
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/519612.html
標籤:vba细绳
