VB 下面的公式,BZX_A = Cells(14,16)XBZX_A = Cells(61,35)BZX_B = Ce

1个回答

  • '用循环加数组可以简化,代码如下:

    Dim i As Integer

    Dim BZX(1 to 32) As String, XBZX(1 to 32) As String

    For i = 1 to 32

    BZX(i) = Cells(13 + i, 16)

    XBZX(i) = Cells(60 + i, 35)

    If BZX(i) = "" Then Cells(13 + i,16) = XBZX(i)

    Next

    '如果你仅仅只是判断cells(14,16) = "" 那么 Cells(14,16)就等于 Cells(61,35)

    '那么上面的代码可以简化为:

    Dim i As Integer

    For i = 1 to 32

    If Cells(13 + i, 16) = "" Then Cells(13 + i,16) = Cells(60 + i, 35)

    Next