選択範囲のスペース削除
Sub 選択範囲のスペース削除()
Dim rng As Range
Dim txt As String
For Each rng In Selection.Cells
txt = rng.Value
txt = Replace(txt, " ", "")
txt = Replace(txt, " ", "")
rng.Value = txt
Next rng
MsgBox "完了"
End Sub
選択範囲のカッコを削除
Sub 選択範囲のカッコを削除()
Dim rng As Range
Dim txt As String
For Each rng In Selection.Cells
txt = rng.Value
txt = Replace(txt, "(", "")
txt = Replace(txt, ")", "")
txt = Replace(txt, ")", "")
txt = Replace(txt, "(", "")
rng.Value = txt
Next rng
MsgBox "完了"
End Sub
特定の文字が含まれていた場合、文字を削除
Sub 特定の文字が含まれていた場合文字を削除()
Dim my_array As Variant
Dim s_row, s_col As Long
Dim max_row, max_col As Long
s_row = 2 'データの開始行を設定
s_col = 1 'データの開始列を設定
max_row = ThisWorkbook.ActiveSheet.Cells(Rows.Count, s_col).End(xlUp).Row
max_col = ThisWorkbook.ActiveSheet.Cells(s_row, Columns.Count).End(xlToLeft).Column
Set my_array = Range(Cells(s_row, s_col), Cells(max_row, max_col))
Set myrange = my_array
keyWord1 = "店"
keyWord2 = ""
bool = myrange.Replace(keyWord1, keyWord2, LookAt:=xlPart)
MsgBox "完了"
End Sub
解説
- LookAt:=xlWhole:完全一致
- LookAt:=xlPart:部分一致
コメント