Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 带变量的参考单元格位置_Vba_Excel - Fatal编程技术网

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"