【问题标题】:VBA INDEX MATCH LOOPVBA 索引匹配循环
【发布时间】:2015-10-30 18:02:22
【问题描述】:

如何在 VBA 中循环我的索引匹配函数?

目前我的索引匹配工作正常 - 我现在需要它来遍历“Table2”中的所有行并在“table1”中找到匹配值

每次运行工作簿中内置的查询时,表 1、“N”和“I”的填充行数都会发生变化。在运行 for 和 while 循环时,我不断收到语法错误(我对 VBA 很陌生)

请帮忙!

谢谢,

total = Application.WorksheetFunction.Index(Sheets("table1").Range("I16:I100"), Application.WorksheetFunction.Match(Sheets("Table2") _
.Range("B2"), Sheets("table1").Range("N16:N100"), 0))

【问题讨论】:

    标签: excel vba loops indexing


    【解决方案1】:

    这样的事情怎么样?

    Dim rng As Range, cell As Range
    
    'initialize the Range object rng with Range("A1:A10")
    Set rng = Range("A1:A10")
    'Or if you prefer:
    Set rng = Selection
    
    'Add the For Each Next loop.
    For Each cell In rng
    
    'Do stuff
    
    Next cell
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-27
      • 2020-08-15
      • 1970-01-01
      • 2020-10-06
      • 1970-01-01
      • 2015-12-15
      • 1970-01-01
      • 2021-08-25
      相关资源
      最近更新 更多