循环范围并根据单元格值

时间:2017-08-06 21:30:29

标签: vba excel-vba loops excel

您好我有一张名为"摘要"我在D6 - D26栏中有20家公司。我希望循环遍历每个单元格,将单元格值转到一个名为" Tape"筛选该值的Z列,并将结果值从A列移到AC,并将其粘贴到名为" Collat​​eral"的选项卡中。以下是我到目前为止的情况。

Sub Pricing_Export()


Dim wsInput As Worksheet
Dim DataIn As Range
Set wsInput = Worksheets("Tape")

Dim wsOutput As Worksheet
Set wsOutput = Worksheets("Collateral")

Dim wsSummary As Worksheet
Set wsSummary = Worksheets("Summary")

With wsSummary.Range("D6")

Dim qCell As Range
For Each qCell In .Range("D6:D11")

    qCell.Copy

    DoEvents
    'Application.Wait (Now + TimeValue("0:00:05"))
    wsInput.Select
    'LastRow = wsMain.Cells(1, 2).End(xlDown).Row
    'LastCol = wsMain.Cells(1, 2).End(xlToRight).Column
    ActiveSheet.Range("$A$1:$AO$25000").AutoFilter Field:=40, 
Criteria1:=qCell.Value
    Set DataIn = Range(Cells(1, 2), Cells(LastRow, LastCol))
    DataIn.Copy
    wsCollateral.Range("B1").Select
    Selection.End(xlToLeft).Offset(ColumnOffset:=1).PasteSpecial 
xlPasteValues

Next

End With


End Sub

0 个答案:

没有答案