我目前正在学习自己的vba,所以提前感谢您花时间阅读本文。 我已经研究了很多,并且遇到了关于我公式变量的vba错误,代码如下:
public class Game {
public int Id { get; set; }
public virtual ICollection<GamePlayer> Players { get; set; }
}
public enum Color { White = 1, Black = 2}
public class GamePlayer {
public int Id { get; set; }
public virtual Game GamePlayed { get; set; }
public Color PlayedAs { get; set; }
public virtual Player Player { get; set; }
}
public class Player {
public virtual ICollection<GamePlayer> Games { get; set; }
}
这就是我要做的事情&#34;自动&#34;使用For语句
Dim i As Long
Dim j As Long
Dim k As Integer
Dim iVal As Byte
With ActiveSheet
iVal = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
j = 2
k = -1
For i = 3 To iVal
j = j+1
k = k-1
Range("L3").Select
ActiveCell.FormulaR1C1 = "=IF(R" & i & "C5=R[" & k & "])"
'ActiveCell.FormulaR1C1 = "=+IF(R3C5=R[-2]C,R3C1,"" "")"
Selection.AutoFill Destination:=Range("L" & i & ": W" & i), Type:=xlFillDefault
我认为我非常接近但必须是一个我遗漏的小细节,谢谢。
答案 0 :(得分:2)
试试这个:
Range("L" & i & ":W" & i).FormulaR1c1 = "=IF(R" & i & "C5 = R[" & k & "]C,R" & i & "C1,"" "")"
使用r1c1时,无需自动填充。
答案 1 :(得分:0)
在我看来,你只需要:
Range("L3:W" & iVal).FormulaR1C1 = "=IF(RC5=R1C,RC1,"" "")"