Excel自动填充宏未应用到Y列,但它正在执行其他列

时间:2018-12-06 06:02:22

标签: excel vba

我遇到了一个问题,希望有人可以解决!

我的代码:

Dim lastrow1 As Long
lastrow1 = Range("R" & Rows.Count).End(xlUp).Row
Dim lastrow2 As Long
lastrow2 = Range("T" & Rows.Count).End(xlUp).Row
Dim lastrow3 As Long
lastrow3 = Range("V" & Rows.Count).End(xlUp).Row
Dim lastrow4 As Long
lastrow4 = Range("X" & Rows.Count).End(xlUp).Row

Columns("S:S").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove   

Columns("U:U").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove   

Columns("W:W").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove   

Columns("Y:Y").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove 

Range("S1").Select
ActiveCell.FormulaR1C1 = "CreateValue"
Range("S2").Select
ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])"
Range("S2").Select
Selection.AutoFill Destination:=Range("S2:S" & lastrow1)
Range("S2:S" & lastrow1).Select

Range("U1").Select
ActiveCell.FormulaR1C1 = "PublishValue"
Range("U2").Select
ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])"
Range("U2").Select
Selection.AutoFill Destination:=Range("U2:U" & lastrow2)
Range("U2:U" & lastrow2).Select

Range("W1").Select
ActiveCell.FormulaR1C1 = "CloseValue"

Range("W2").Select
ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])"
Range("W2").Select
Selection.AutoFill Destination:=Range("W2:W" & lastrow3)
Range("W2:W" & lastrow3).Select

Range("Y1").Select

ActiveCell.FormulaR1C1 = "AwardValue"

Range("Y2").Select
ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])"
Range("Y2").Select
Selection.AutoFill Destination:=Range("Y2:Y" & lastrow4)
Range("Y2:Y" & lastrow4).Select

会发生什么情况,自动填充适用于S U W列,但不适用于Y列。在Y列中,标头被=value()公式替换,并且仅对Y2复制。即Y3开始是空的!

感谢您的帮助

谢谢!

0 个答案:

没有答案