|
按照你要求做了修改
Option Explicit
Sub test()
Dim arr, brr, crr, i&, j&, s(1), m(1)
arr = Sheets(2).Range("a1").CurrentRegion
ReDim brr(1 To UBound(arr) - 1, 1 To 1), crr(1 To UBound(arr) - 1, 1 To 1)
For j = 1 To UBound(arr, 2)
If arr(1, j) = "库位" Then
s(0) = j
ElseIf arr(1, j) = "客户代码" Then
s(1) = j
End If
Next
For i = 2 To UBound(arr)
m(0) = Empty: m(1) = Empty
If Len(s(0)) Then
If arr(i, s(0)) Like "*[a-z]*" Then
For j = 1 To Len(arr(i, s(0)))
If Mid(arr(i, s(0)), j, 1) Like "*[a-z]*" Then
m(0) = m(0) & UCase(Mid(arr(i, s(0)), j, 1))
Else
m(0) = m(0) & Mid(arr(i, s(0)), j, 1)
End If
Next
brr(i - 1, 1) = m(0)
Else
brr(i - 1, 1) = arr(i, s(0))
End If
End If
If Len(s(1)) Then
If arr(i, s(1)) Like "*[a-z]*" Then
For j = 1 To Len(arr(i, s(1)))
If Mid(arr(i, s(1)), j, 1) Like "*[a-z]*" Then
m(1) = m(1) & UCase(Mid(arr(i, s(1)), j, 1))
Else
m(1) = m(1) & Mid(arr(i, s(1)), j, 1)
End If
Next
crr(i - 1, 1) = m(1)
Else
crr(i - 1, 1) = arr(i, s(1))
End If
End If
Next
If Len(s(0)) Then Sheets(2).Cells(2, s(0)).Resize(UBound(brr), 1) = brr
If Len(s(1)) Then Sheets(2).Cells(2, s(1)).Resize(UBound(crr), 1) = crr
End Sub
|
评分
-
查看全部评分
|