我是VBA的新手所以请耐心等待。我对这段代码很难:
Dim arrayAC() As Variant
Dim arrayW() As Variant
Dim DD As date
Dim LrowAC As Integer
Dim LrowW As Integer
LrowAC = Worksheets("A").Columns(29).Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
LrowW = Worksheets("A").Columns(23).Find(What:="*", LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
ReDim arrayAC(1 To LrowAC + 1)
ReDim arrayW(1 To LrowW + 1)
For i = 3 To LrowAC + 1
arrayAC(i) = Worksheets("A").Cells(i, 29)
Next i
i = 3
For h = 3 To LrowW + 1
arrayW(h) = Worksheets("A").Cells(h, 23)
Next h
h = 3
For i = 3 To LrowAC + 1
For h = 3 To LrowW + 1
If arrayAC(i) = arrayW(h) Then
DD = arrayAC(i)
Worksheets("A").Cells(i, "X").Value = DD
end if
next h
next i
DD没有任何价值!我不知道如何将arrayAC(i)保存在DD变量中,稍后将在excel表中打印。谢谢,
答案 0 :(得分:0)
执行此操作,如果您看到消息框,则应将值写入X列。如果您没有看到消息框,那么您的假设就会出现其他问题。如果你多次看到消息框,你可能会覆盖x列中的单元格,进一步调试是必要的......
For i = 3 To LrowAC + 1
For h = 3 To LrowW + 1
If arrayAC(i) = arrayW(h) Then
'DD = arrayAC(i)
msgbox arrayAC(i)
Worksheets("A").Cells(i, "X").Value = arrayAC(i)
end if
Next
Next