Sub addbdh()
Dim i As Integer
Dim n As Integer
Range("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
n = Selection.Count
For i = 1 To n
Cells(3, i * 2 - 1).Formula = "=BDH(B" & i * 2 - 1 & ",A1 ,B1 ,Today())"
Next i
End Sub
最初的目的是在第三行的列中引入一个公式,但每次循环循环时都跳过中间的一列。
尽管如此,我意识到我的代码适用于刚刚描述但经过转置的概念(跳过行以在B列的行中引入公式)。
由于列是用字母命名的,我不知道如何在formula en元素内的循环中引入跳过列,就像我在指令中对行所做的那样:
Cells(3, i * 2 - 1).Formula = "=BDH(B" & i * 2 - 1 & ",A1 ,B1 ,Today())"
"=BDH(B" & i * 2 - 1 & ",A1 ,B1 ,Today())"
为了每次跳过一列,而不是一行。
有人能帮我吗?
非常感谢