此短脚本在“下一个”中断。我想将这些数据保存在一个集合中,这样我就可以转储和定制它在整个工作簿中的显示方式。感谢您的帮助刮掉数据并粘贴到单独的工作表的工作表
编辑:更新我的代码。仍然遇到问题。
资源类
''''''''''''''''''''''
' 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
哪里都是确切的错误,你的脚本看起来不完美 – Kasnady 2013-04-05 18:52:58
@Never_Mind “下一步不为” – STANGMMX 2013-04-05 19:27:23
所以。你已经通过你自己找到答案了吗? – Kasnady 2013-04-05 19:30:41