マクロコード:駅前探検クラブ 短縮
私はよく行くような場所だと、駅前探検クラブの検索結果を、エクセルの1コのセルにとりあえず貼り付けて、その後携帯にメールに送るときがあるのだが、そのままだとムダな文字と改行が多いのだ。そんなわけで、次のマクロを作った。単純にいらない部分を置換かけて、いらない改行をのぞいただけ。以前別の日記で書いた、”改行なし”の場合に使う改行を示すコードは"" & Chr(10) & ""なんだよね。今回の収穫はこれだ!貼り付けるときは、出発駅の左から、到着駅の到着時間までをそのまま貼り付け。ちなみに、WINDOWS XPだったと思うが。。。。エクセルは2003だったかな。。。Private Sub CommandButton1_Click()' 出発削除 Macro 改行等も改良20060821' Cells.Replace What:="(普通)", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:="東京メトロ", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:="△", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:="地図 ", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:="[ ", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:=" ]", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:=" | 時刻表 | 出口 ", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:=" | 時刻表 ", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:="| 乗車位置 ", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False '改行マーク" & Chr(10) & " Cells.Replace What:="" & Chr(10) & "", Replacement:="", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:="発", Replacement:="発" & Chr(10) & "", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:="着", Replacement:="着" & Chr(10) & "", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:=" ", Replacement:=" ", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:=" ", Replacement:=" ", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Cells.Replace What:=" ", Replacement:=" ", LookAt:=xlPart, SearchOrder _ :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False ActiveWorkbook.Save End Sub