我尝试运行下面的代码,但始终收到错误消息“对象不支持此属性或方法”。是否因为.Formula引用整数i而不是实际单元格?非常感谢任何反馈!已经为此苦苦挣扎了一段时间://谢谢您!
Sub GetModelDescr()
Dim lastRow As Long
Dim i As Long
Dim rng As Range
Dim r As Range
Worksheets("Stock").Activate
With Worksheets("Stock")
lastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
Set rng = .Range("B2:B" & lastRow)
For i = 1 To rng.Rows.Count
Set r = rng.Cells(i, 2)
.Formula "=TRIM(RC[6])&"" ""&MID(RC[-1],7,3)&"" ""&RIGHT(RC[-1],4)"
.Value2 = .Value2
Next i
End With
End Sub