▽1
●
きゃづみぃ ●50ポイント ベストアンサー |
Sub 文字変換() Dim l As Long 列 = "A" For l = 1 To Cells(Rows.Count, 列).End(xlUp).Row a = Cells(l, 列) Cells(l, 列) = StrConv(Cells(l, 列), vbNarrow) If a <> Cells(l, 列) Then Cells(l, 列).Interior.Color = 65535 End If Next l End Sub
変換したところは 黄色にしました。
列に 変換したい列をセットしてください。
半角全部変換しています。
Sub 大文字変換() Dim l As Long 列 = "A" For l = 1 To Cells(Rows.Count, 列).End(xlUp).Row a = Cells(l, 列) Cells(l, 列) = henkan(Cells(l, 列)) If a <> Cells(l, 列) Then Cells(l, 列).Interior.Color = 65535 End If Next l End Sub Function henkan(aa As String) As String d = "" For b = 1 To Len(aa) c = Mid(aa, b, 1) If c >= "A" And c <= "Z" Then c = StrConv(c, vbNarrow) End If If c >= "a" And c <= "z" Then c = StrConv(c, vbNarrow) End If If c = "?" Then c = StrConv(c, vbNarrow) End If d = d & c Next b henkan = d End Function
ローマ字とハイフンのみです。
http://q.hatena.ne.jp/1377137035
関数ASCを使ってできます。
=ASC(文字列) ■全角文字を半角にする
http://kokodane.com/kan35.htm
fと?だけ置換したいなら、SUBSTITUTE関数を入れ子にして使います。
=SUBSTITUTE(SUBSTITUTE(セル名,"f","f"),"?", "-")