简体   繁体   English

Excel Macro VBA for循环?

[英]Excel Macro VBA for loop?

I have three sets of data: 我有三组数据:

first set of data in Cell "D2" to "F107" in "Sheet1" second set of data in Cell "G2" to "G572" in "Sheet2" third set of data in Cell "I2" to "I572" in "Sheet2" “ Sheet1”中单元“ D2”至“ F107”中的第一组数据“ Sheet2”中单元“ G2”至“ G572”中的第二组数据“ Sheet2”中单元“ I2”至“ I572”中的第三组数据”

can anyone please help for the VBA coding if I want to perform the actions below: 如果我要执行以下操作,谁能请VBA编码帮助:

by using each data in the first set to search within the second set of data, if found a contain, return to the third set of data value 通过使用第一组中的每个数据在第二组数据中进行搜索,如果找到包含,则返回到第三组数据值

for example: 例如:

if VBA finds a contain of Cell "E19" in "Sheet1" in the Cell "G200" in "Sheet2", then it returns Cell "I200" in "Sheet2" 如果VBA在“ Sheet2”的单元格“ G200”的“ Sheet1”中找到单元格“ E19”的包含,则它将在“ Sheet2”中返回单元格“ I200”

thank you 谢谢

Dim i As string
Dim j As string
Dim k As string

For i = 2 To 107
    For j = 4 To 6
        For k = 2 To 573
            If Sheet1.Cells(i, j) = Sheet2.Cells(k, 7) Then
                sheet3.Cells(k, 9) ' you code
            End If
        Next k
    Next j
Next i

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM