Excel VBA使单元格序列等于一个值。 将每年的虚拟转换为季度

我如何编写一个函数或macros来将年度虚拟variables转换为季度?
特别是我想:假设在单元格A1我有值0,我想B(1:4)0.然后A2 = 0,我想B(5:8)0.然后A3 = 1 B(8:11)= 1以A列5000个单元格为单位。 任何帮助将不胜感激!

好的,试试这个。

Public Sub fillCell() Dim row, bRow, startRow, endRow As Integer startRow = 1 endRow = 4 With Sheets("sheetname") 'Looping from 1 to 5000, increase by 1 For row = 1 To 5000 Step 1 For bRow = startRow To endRow .Range("B" & bRow) = .Range("A" & row) Next bRow startRow = startRow + 4 endRow = endRow + 4 Next row End With End Sub