这个简短的脚本在“下一步”中断。我想将此数据保存在一个集合中,以便我可以转储和自定义它在工作簿中的呈现方式。谢谢你的帮助
编辑:更新了我的代码。仍然遇到问题。
资源类
''''''''''''''''''''''
' Name property
''''''''''''''''''''''
Public Property Get Name() As String
Name = pName
End Property
Public Property Let Name(Value As String)
pName = Value
End Property
''''''''''''''''''''''
' City property
''''''''''''''''''''''
Public Property Get City() As String
City = pCity
End Property
Public Property Let City(Value As String)
pCity = Value
End Property
''''''''''''''''''''''
' Title property
''''''''''''''''''''''
Public Property Get Title() As String
Title = pTitle
End Property
Public Property Let Title(Value As String)
pTitle = Value
End Property
剧本
Sub searchResources()
Dim a As Range
Dim cell As Variant
Dim Resources As Collection
Dim Emp As Resource
Dim Count As Integer
For Each cell In a.Rows
If cell.Value = "Dallas" Or cell.Value = "Oklahoma City" Or cell.Value = "Houston" Then
Set Emp = New Resource
Emp.City = cell.Value
cell.Offset(0, -2).Select
Emp.Title = cell.Value
cell.Offset(0, -1).Select
Emp.Name = cell.Value
Resources.Add Emp
End If
Resume Next
For Each Emp In Resources
ActiveWorkbook.Sheets("A").Activate
a.Select
Debug.Print Emp.Name
Debug.Print Emp.City
Debug.Print Emp.Title
Next Emp
End Sub