Vba 带变量的参考单元格位置
我需要使用变量引用单元格位置,以下是代码:Vba 带变量的参考单元格位置,vba,excel,Vba,Excel,我需要使用变量引用单元格位置,以下是代码: Dim jj As Integer jj = 1 Do While jj <= x if Cells(jj, 2) = "Some Criteria" Then Cells(jj, 3).Formula = "=Cells(jj,1)^2" jj = jj + 1 Else jj = jj + 1 End If Loop Dim jj作为整数 jj=1 当jj使用R1C1符号时
Dim jj As Integer
jj = 1
Do While jj <= x
if Cells(jj, 2) = "Some Criteria" Then Cells(jj, 3).Formula = "=Cells(jj,1)^2"
jj = jj + 1
Else
jj = jj + 1
End If
Loop
Dim jj作为整数
jj=1
当jj使用R1C1
符号时,请执行以下操作:
if Cells(jj, 2) = "Some Criteria" Then Cells(jj, 3).FormulaR1C1 = "=RC1^2"
或者您可以计算A1
表示法公式,例如
if Cells(jj, 2) = "Some Criteria" Then Cells(jj, 3).Formula = "=$A" & jj & "^2"
为此使用R1C1
符号:
if Cells(jj, 2) = "Some Criteria" Then Cells(jj, 3).FormulaR1C1 = "=RC1^2"
或者您可以计算A1
表示法公式,例如
if Cells(jj, 2) = "Some Criteria" Then Cells(jj, 3).Formula = "=$A" & jj & "^2"