[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『タイトル名で列を選択してマクロを実行』(ライスペーパー)
Sheet1のA列にタイトルがあり、「メモ」というタイトルの列にのみ、下記のマクロを実行したいのですが、うまくいきません。どのようにやるのか教えて下さい。
よろしくお願い致します。
Sheets("Sheet1").Select Selection.Replace What:="A", Replacement:="1", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _ ReplaceFormat:=False Selection.Replace What:="B", Replacement:="2", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _ ReplaceFormat:=False Selection.Replace What:="C", Replacement:="3", LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=True, SearchFormat:=False, _ ReplaceFormat:=False Range("A1").Select End Sub
< 使用 Excel:Excel2007、使用 OS:Windows7 >
とりあえず、1行目のどこかに「メモ」があると仮定した場合の例なぞ。
Sub test() Dim i As Long
For i = 1 To Cells(1, Columns.Count).End(xlToLeft).Column If Cells(1, i).Value = "メモ" Then With Columns(i) .Replace What:="A", Replacement:="1" .Replace What:="B", Replacement:="2" .Replace What:="C", Replacement:="3" End With Exit For End If Next i End Sub (???) 2016/04/28(木) 10:54
回答ありがとうございます。
おっしゃるとおり1行目のどこかに「メモ」があります。
こちらで、上手く変換されました。
ありがとうございました。
(ライスペーパー) 2016/04/28(木) 13:13
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.