|
こんなのでも善いかも?
Option Explicit
Public Sub Sample()
'データの列数(I列〜AC列の21列)
Const clngColumns As Long = 21
Dim i As Long
Dim vntData As Variant
Dim vntUs As Variant
Dim vntJp As Variant
'USサイズの一覧
vntUs = Array("4", "4H", "5", "5H", "6", "6H", "7", _
"7H", "8", "8H", "9", "9H", "10", "F")
'対応するサイズの一覧
vntJp = Array("22.5", "23", "23.5", "24", "24.5", "25", "25.5", _
"26", "26.5", "27", "27.5", "28", "28.5", "フリー")
'範囲を配列に取得
With Worksheets("靴").Range("I2")
'データを配列に取得
vntData = .Resize(, clngColumns).Value
'USサイズを対応サイズに変換
For i = 1 To UBound(vntData, 2)
vntData(1, i) = SizeConv(vntData(1, i), vntUs, vntJp)
Next i
'配列をシートに出力
.Resize(, clngColumns).Value = vntData
End With
MsgBox "処理が完了しました", vbInformation
End Sub
Private Function SizeConv(vntValue As Variant, vntUs As Variant, vntJp As Variant) As Variant
Dim i As Long
Dim lngMax As Long
'添え字の最大値
lngMax = UBound(vntUs)
'USサイズに合致する物が有るか比較
For i = 0 To lngMax
'合致した場合Forを抜ける
If StrComp(vntValue, vntUs(i), vbTextCompare) = 0 Then
Exit For
End If
Next i
'合致した場合
If i <= lngMax Then
'対応するサイズを返す
SizeConv = vntJp(i)
Else
'引数を返す
SizeConv = vntValue
End If
End Function
|
|