| 
    
     |  | いつもお世話になっています。 どうしてもうまくいかないので、教えてください。
 環境は、Vista、2007です。
 
 下記のように作りました。
 どこが悪いのでしょうか?
 
 Private Sub Cmd作成_Click()
 
 Dim 年 As Integer
 Dim 月 As Integer
 Dim 月末日 As Date
 Dim セル As Range
 Dim cell As Range
 
 年 = Txt年.Value
 月 = Txt月.Value
 月末日 = Txt月末日.Value
 
 Sheets("★月分").Copy After:=Sheets("★月分")
 ActiveSheet.Name = 月 & "月分"
 
 If 月 = 1 Then
 For Each セル In Selection
 セル.Replace What:="/25", Replacement:=年 - 1 & "/12/25"
 セル.Replace What:="/27", Replacement:=年 - 1 & "/12/27"
 セル.Replace What:="/31", Replacement:=年 - 1 & "/12/31"
 セル.Replace What:="/1", Replacement:=年 & "/1/1"
 セル.Replace What:="/5", Replacement:=年 & "/1/5"
 セル.Replace What:="/6", Replacement:=年 & "/1/6"
 セル.Replace What:="/8", Replacement:=年 & "/1/8"
 セル.Replace What:="/20", Replacement:=年 & "/1/20"
 セル.Replace What:="/21", Replacement:=年 & "/1/21"
 セル.Replace What:="/24", Replacement:=年 & "/1/24"
 Next セル
 Else
 For Each セル In Selection
 セル.Replace What:="/25", Replacement:=年 & "/" & 月 - 1 & "/25"
 セル.Replace What:="/27", Replacement:=年 & "/" & 月 - 1 & "/27"
 セル.Replace What:="/31", Replacement:=月末日
 セル.Replace What:="/1", Replacement:=年 & "/" & 月 & "/1"
 セル.Replace What:="/5", Replacement:=年 & "/" & 月 & "/5"
 セル.Replace What:="/6", Replacement:=年 & "/" & 月 & "/6"
 セル.Replace What:="/8", Replacement:=年 & "/" & 月 & "/8"
 セル.Replace What:="/20", Replacement:=年 & "/" & 月 & "/20"
 セル.Replace What:="/21", Replacement:=年 & "/" & 月 & "/21"
 セル.Replace What:="/24", Replacement:=年 & "/" & 月 & "/24"
 Next セル
 End If
 
 End Sub
 
 まったく置換えができません。
 /25だけ置き換えられる時もあるのですが、
 12/252012/1/2011となってしまいます。
 ちなみに、Txt年.ValueはYear(Date) + 1が入っています。
 
 教えてください。
 よろしくお願いします。
 
 |  |