2007年9月27日木曜日

Excelにてカタカナを全角、英数記号を半角に変換する。


'rwmin : 開始行
'rwmax : 終了行
'col : 列番号
Sub change(rwstart as integer,rwend as integer,col as integer)
Dim i As Integer
Dim j As Integer
Dim result As String
Dim temp As String

For i = rwstart To rwend
result = ""
For j = 1 To Len(Cells(i, col))
temp = Mid(Cells(i, col), j, 1)
temp = StrConv(temp, vbNarrow)
If (Asc(temp) >= &HA6) And (Asc(temp) <= &HDF) Then
temp = StrConv(temp, vbWide)
  End If
  result = result + temp
     Next j
     Cells(i, col) = result
   Next i
End Sub

0 件のコメント: