SSブログ

Excel2000 VBA 選択範囲の文字列の置換 [Excel2000 VBA独習]

Excel2000 VBA 選択範囲の文字列の置換

Sub 範囲置換()
'
'testバージョン
'
On Error GoTo owari  'inputboxでキャンセルボタンが押された時の処理のつもり

Dim target As Range
Dim hani, s As Range
Dim str_mae, str_go, x As String

'InputBoxで選択範囲を取得
   Set hani = Application.InputBox(Title:="置換する範囲を選択してください!", prompt:="範囲選択文字列の置換", Type:=8)

'置換対象文字
   str_mae = Application.InputBox(Title:="置換する文字!", prompt:="置換する文字を入力", Type:=2)

'置換後文字
   str_go = Application.InputBox(Title:="置換後の文字!", prompt:="置換後の文字を入力", Type:=2)

'選択範囲 置換
    For Each target In hani
        target.Value = Replace(target.Value, str_mae, str_go)
    Next target
   
owari:
    Set hani = Nothing  '解除
 
End Sub

 


タグ:Excel2000 VBA
nice!(0)  コメント(0)  トラックバック(0) 
共通テーマ:パソコン・インターネット

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。