Следующее ожидает, что Sheet1 и Sheet2 будут именами.И идет на 158 кварталов.
Option Explicit
Sub doFromThru()
' clear contents
Sheets("Sheet2").Select
Cells.Select
Selection.ClearContents
Range("A1").Select
Cells(1, "A") = "CRD"
Cells(1, "B") = "Year"
Cells(1, "C") = "Quarter"
Cells(1, "D") = "QuarterNumerical"
Cells(1, "E") = "Disclosure"
Dim nOutRow As Integer
nOutRow = 1
' step thru all the rows on the input sheet
Dim nInRow As Long, maxInRow As Long, nInCRD As String, nInDisc As String
maxInRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
For nInRow = 2 To maxInRow
nInCRD = Sheets("Sheet1").Cells(nInRow, "A")
nInDisc = Sheets("Sheet1").Cells(nInRow, "L")
' create the new rows on Sheet2
Dim dFrom As String, nQtr As Integer
dFrom = DateValue("Oct 1978") ' starting from here
For nQtr = 1 To 158
nOutRow = nOutRow + 1
Sheets("Sheet2").Cells(nOutRow, "A") = nInCRD
Sheets("Sheet2").Cells(nOutRow, "B") = Format$(dFrom, "yyyy")
Sheets("Sheet2").Cells(nOutRow, "C") = Format$(dFrom, "Q")
Sheets("Sheet2").Cells(nOutRow, "D") = nQtr
Sheets("Sheet2").Cells(nOutRow, "E") = nInDisc
dFrom = DateAdd("Q", 1, dFrom)
Next nQtr
Next nInRow
End Sub
Добавьте немного диагностики, чтобы рассказать вам больше.После nOutRow = nOutRow + 1
Sheets("Sheet2").Cells(1, "G") = nInRow
Sheets("Sheet2").Cells(1, "H") = nOutRow
Sheets("Sheet2").Cells(1, "I") = nQtr
Sheets("Sheet2").Cells(1, "J") = nInDisc