Sub ex()
Dim a As Object
Dim x%, QQ%
For Each a In Range([D10], [O10].End(4))
For x = 1 To Len(a)
If IsNumeric(Mid(a, x, 1)) = True Then QQ = QQ + 1
If QQ = 3 Then a.Value = WorksheetFunction.Replace(a, 1, x, ""): QQ = 0: Exit For
Next
Next作者: peter95 時間: 2020-10-26 13:22
Sub TEST()
Dim Arr, R&, T$, C&, K%
With Range([D10], [O65536].End(3))
Arr = .Value
For C = 1 To .Columns.Count
For R = 1 To .Rows.Count
T = Arr(R, C)
If T Like "*.*.*" Then Arr(R, C) = Mid(T, IIf(Left(T, 1) = "-", 6, 5)): K = 1
Next R
Next C
If K = 1 Then .Value = Arr
End With
End Sub作者: hcm19522 時間: 2020-11-1 10:42
Option Explicit
Sub TEST_1()
Dim Brr, i&, j%, xA As Range
'↑宣告變數
Set xA = Range([D10], [O65536].End(3)): Brr = xA
'↑令xA變數是D~O欄儲存格,令Brr變數是 二維陣列,以xA變數值帶入
For i = 1 To UBound(Brr)
'↑設陣列縱向迴圈
For j = 1 To UBound(Brr, 2)
'↑設陣列橫向迴圈
Brr(i, j) = Mid(Replace(Brr(i, j), "-", ""), 5)
'↑令陣列值去除"-"後,取第5字(含)後的字串
Next
Next
xA = Brr
'↑令xA變數值是 Brr陣列值
Set xA = Nothing: Erase Brr
'↑令釋放變數
End Sub