- 締切済み
表計算
Sub TaskManager() Dim i As Integer Dim Maxval As Integer Dim Counter As Integer Dim AtoShoriFlg As String Set SH1 = Worksheets("Sheet1") Set SH2 = Worksheets("Sheet2") Maxval = WorksheetFunction.Max(Range("B:B")) Maxval = Maxval + 1 '初期値設定 i = 7 AtoShoriFlg = "ON" Counter = 1 Do While Cells(i, 4).Value <> "end" Select Case Cells(i, 4) Case Is = "新規エントリー" AtoShoriFlg = "OFF" i = i + 1 Case Is = "" Cells(i - 1, 4).Copy Cells(i, 4) Cells(i, 4).Font.Color = RGB(255, 255, 255) SH1.Range(SH1.Cells(i, 2), SH1.Cells(i, 6)).Borders(xlEdgeTop).LineStyle = xlLineStyleNone Case Is <> Cells(i - 1, 4) SH1.Range(SH1.Cells(i, 2), SH1.Cells(i, 6)).Borders(xlEdgeTop).LineStyle = xlContinuous SH1.Range(SH1.Cells(i, 2), SH1.Cells(i, 6)).Font.Color = RGB(0, 0, 0) If Cells(i, 2) = "" Then Cells(i, 2) = Maxval Maxval = Maxval + 1 End If Counter = 1 Case Else SH1.Range(SH1.Cells(i, 2), SH1.Cells(i, 6)).Borders(xlEdgeTop).LineStyle = xlLineStyleNone End Select If Cells(i, 2).Value = "" Then Cells(i, 2) = Cells(i - 1, 2).Value Cells(i, 2).Font.Color = RGB(255, 255, 255) End If If Cells(i, 3).Value = "" And Counter <> 1 Then Cells(i, 3) = Cells(i - 1, 3).Value Cells(i, 3).Font.Color = RGB(255, 255, 255) End If If AtoShoriFlg = "ON" Then Cells(i, 7) = Counter Counter = Counter + 1 End If i = i + 1 Loop SH1.Range(SH1.Cells(i, 2), SH1.Cells(i, 6)).Borders(xlEdgeTop).LineStyle = xlContinuous If AtoShoriFlg = "ON" Then SH2.Range("B2:F5").Copy Destination:=SH1.Cells(i, 2) End If End Sub
- みんなの回答 (1)
- 専門家の回答
みんなの回答
- imogasi
- ベストアンサー率27% (4737/17070)