传说中较快点的代码

Sub fillCells()
    Dim wst As Worksheet
    Dim title As Variant, rncArr As Variant, dataRange As Variant
    Dim maxDate As Date, minDate As Date
    Dim i As Integer, j As Integer, row As Integer, endRow As Integer
    Set wst = Worksheets("Sheet5")
    title = Array("RNC", "Date", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9")
    rncArr = Array("RNC1", "RNC2", "RNC3", "RNC4", "RNC5", "RNC6", "RNC7", "RNC8", "RNC9", "RNC10")
    minDate = #7/20/2010#
    maxDate = #9/27/2010#
    row = 1
    wst.Range(wst.Cells(1, 1), wst.Cells(1, UBound(title) + 1)) = title
    endRow = (UBound(rncArr) + 1) * (maxDate - minDate + 1) + 1
    dataRange = wst.Range(wst.Cells(2, 1), wst.Cells(endRow, 2)).Value
    For i = 1 To UBound(rncArr) + 1
        For j = 1 To (maxDate - minDate + 1)
            dataRange(row, 1) = rncArr(i - 1)
            dataRange(row, 2) = minDate + j - 1
            row = row + 1
        Next j
    Next i
    wst.Range(wst.Cells(2, 1), wst.Cells(endRow, 2)).Value = dataRange
End Sub

转载于:https://www.cnblogs.com/wanyakun/archive/2011/09/17/2179555.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值