我正在尝试遍历 Excel 中的 A 列。检查它是否有值,如果有,移动到 b 列中的相邻单元格并检查该值并将其存储以用于搜索。
我什至无法通过 A 列的循环工作。我已经查看了数百个示例以及我应该使用的示例。
有人可以指出缺少什么吗?这是我的代码:
Sub AdjacentRow()
Dim xlWrkBk As Excel.Workbook
Dim xlsht As Excel.Worksheet
Dim xl As Excel.Application
Set xl = CreateObject("Excel.Application")
Set xlWrkBk = GetObject("C:\Users\my_username\Desktop\AgileProjects\ITAG Open Interactions.xlsx")
Set xlsht = xlWrkBk.Worksheets(1)
Dim i, j, FirstCell, LastCell As Integer
Dim strIMresult As String
Dim Cell, Row, Column As Excel.Range
'Set Cell = Range("A9").End(xlDown)
'Set Cell = Range([a1], [a250])
For Each Row In Range("A9:A250").Rows
If Not IsEmpty(ActiveCell.Value) Then
'move to adjacent cell
ActiveCell.Offset(0, 1).Select
If Not IsEmpty(ActiveCell.Value) Then
'copy the value
strIMresult = ActiveCell.Value
'ActiveCell.Offset(1, 0).Select
'ActiveCell = strIMresult
Debug.Print strIMresult
Else
ActiveCell.Offset(0, -1).Select
End If
End If
Next Row
End Sub