#3の修正
空のシートから使用開始することを想定しておらず、
性能が悪く、バグがあるので直しました。 <m(__)m>
Option Explicit
Private Sub Workbook_Open()
Dim RowCnt As Long
Dim MaxRow As Long
With ThisWorkbook.Sheets(1)
MaxRow = 365 * 3 * 7
RowCnt = 1
Do
If RowCnt > MaxRow Then Exit Do
'日付の埋まったセル、かつ結合セルが横に3つ、かつ今日の日付、
If ((IsDate(.Cells(RowCnt, 2).Value) = True) And _
(.Cells(RowCnt, 2).MergeArea.Columns.Count = 3) And _
(.Cells(RowCnt, 2).Value = Date)) Then
.Cells(RowCnt, 2).Offset(1, 0).Select
Exit Sub
End If
RowCnt = RowCnt + 1
Loop
If .Cells(2, 2).Value = "" Then
RowCnt = 1
Else
RowCnt = MaxRow
Do
If RowCnt = 1 Then Exit Do
If IsDate(.Cells(RowCnt, 2).Value) = True Then
Exit Do
End If
RowCnt = RowCnt - 1
Loop
RowCnt = RowCnt + 6 '6:使用行数
End If
'MsgBox (RowCnt)
'日付欄
With .Cells(RowCnt + 1, 2).Resize(1, 3) '2列目から3列
.Merge
.Value = Date
.NumberFormatLocal = "yyyy""年""m""月""d""日(""aaa"")"""
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Select
End With
With .Cells(RowCnt + 1, 5).Resize(1, 3) '5列目から3列
.Merge
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.Select
End With
With .Cells(RowCnt + 1, 8).Resize(1, 3) '8列目から3列
.Merge
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.Select
End With
'日記欄
With .Cells(RowCnt + 2, 2).Resize(4, 9) '2列目から4行9列
.Merge
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlTop
.Select
End With
'罫線
With .Cells(RowCnt + 1, 2).Resize(5, 9) '2列目から5行9列
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
End With
With .Borders(xlEdgeTop)
.LineStyle = xlContinuous
End With
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
End With
With .Borders(xlInsideVertical)
.LineStyle = xlContinuous
End With
With .Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
End With
End With
End With
End Sub
お礼
丁寧に回答いただき、感謝いたします。一から一歩一歩学習して行きます。 何か楽しさが少し分かったようです。いろいろとありがとうございました。