这是我第一次在VBA中编写任何内容-我试图遍历一列(RRlist),如果该值大于20,则将有关该单元格的信息从其行添加到另一个单元格(建议)中。我希望所有信息都添加到该单元格中,所以这是一个列表。 当我尝试运行此代码时,电子表格中没有任何反应。
Option Explicit
Public rcomments As String
Public RRlist As Range
Public RRcell As Range
Sub WrittenMacro()
rcomments = ""
Set RRlist = Range("G33:G420")
For Each RRcell In RRlist
If RRcell.Value > 20 Then
rcomments = rcomments & "CUSIP " & RRcell.Offset(, -5).Value & ", " & RRcell.Offset(, -4).Value & "has a return of " & RRcell & "; "
End If
Next RRcell
End Sub