Excel 宏以复制COL并附加到其他COL下,但需要搜索为:";xlother“;有:“;第xlPart";

Excel 宏以复制COL并附加到其他COL下,但需要搜索为:";xlother“;有:“;第xlPart";,excel,vba,Excel,Vba,我终于让它工作了,但它搜索xlPart还有最后一个问题,我需要它搜索xlother,但我不知道在哪里添加xlother 谢谢 Sub MoveUnder() Dim ar As Variant Dim er As Variant Dim i As Variant Dim j As Long Dim k As Long Dim LR As Long Sheets("XXX").Select ar = Array("Target", "Label") ' Find column

我终于让它工作了,但它搜索
xlPart
还有最后一个问题,我需要它搜索
xlother
,但我不知道在哪里添加
xlother

谢谢

Sub MoveUnder()
Dim ar As Variant
Dim er As Variant
Dim i As Variant
Dim j As Long
Dim k As Long
Dim LR As Long


Sheets("XXX").Select

    ar = Array("Target", "Label")     ' Find column to copy
    er = Array("Source", "user name") ' Find column to paste beneath


LR = Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
   For i = LBound(ar) To UBound(ar)
       j = Rows(1).Find(ar(i)).Column
       k = Rows(1).Find(er(i)).Column

         Range(Cells(2, j), Cells(LR, j)).Copy _
           Destination:=Range(Cells(LR, k), Cells(LR, k)).Offset(1, 0)
   Next i
On Error GoTo 0
End Sub
试试这个:

j = Rows(1).Find(ar(i), Rows(1).Cells(Rows(1).Cells.Count), , xlWhole, xlByRows).Column
k = Rows(1).Find(er(i), Rows(1).Cells(Rows(1).Cells.Count), , xlWhole, xlByRows).Column
我在和搜索顺序参数之后添加了


这将从第一个条目(单元格A1)开始搜索第一行。

很好,谢谢L42