●EXCEL・VBA質問スレ Part2●at TECH
●EXCEL・VBA質問スレ Part2● - 暇つぶし2ch82:78
07/06/01 15:05:11
>>81 それを早く(ry  そっちの方が簡単だから。
Private Sub Sample()
Dim targetCell As Range
Dim date1 As Date, date2 As Date, date3 As Date
Dim interval As Integer

Set targetCell = Range("B1") 'Range("B1")の所は最初の年月が入っているセル
Do Until targetCell.Cells(2, 1) = ""
 date1 = CDate(targetCell)
 date2 = CDate(targetCell.Cells(2, 1))
 interval = DatePart("n", date2 - date1)
 If interval = 0 Then
  Rows(targetCell.Cells(2, 1).Row).Delete
  ElseIf interval > 10 Then
   Rows(targetCell.Cells(2, 1).Row).Insert
   date3 = DateAdd("n", 10, date1)
   targetCell.Cells(2, 1) = Format(date3, "yyyy/M/d hh:mm")
   Set targetCell = targetCell.Cells(2, 1)
  Else
   Set targetCell = targetCell.Cells(2, 1)
 End If
  targetCell.Select
Loop
End Sub



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch