尝试遍历一系列单元格并根据另一个单元格中的文本值为它们分配标签。因此,如果单元格 J2 =“此文本”,则单元格 A2 =“此标签”
截至目前,我不断收到运行时错误号 424,说明需要对象
Private Function getPhase(ByVal cell As Range) As String
Select Case cell.Text
Case "Text1"
getPhase = "Label1"
Case "Text2"
getPhase = "Label2"
End Select
End Function
Sub setPhase()
Dim cycle As Range
Dim phase As Range
Set cycle = Range("J2:J10")
Set phase = Range("A2:A10")
For Each cell In phase.Cells
phase.Text = getPhase(cycle)
Next cell
End Sub