【问题标题】:populate sheet A from sheet B - excel VBA从工作表 B 填充工作表 A - excel VBA
【发布时间】:2013-07-12 21:03:57
【问题描述】:

我有以下情况: 我有两个工作表 RAW 和 BOM。我想做的是从 RAW 中为某些组件填充 BOM 表。

例如,在 BOM 工作表中,我有 VXL5-50(以黄色突出显示)。因此,对于该组件,我搜索 sheet1--> 'connector type' 列并查看该字符串是否存在。如果是这样,那么我在 BOM 工作表的 QTY 列中增加 1

这是两张 RAW AND BOM

http://i43.tinypic.com/aos0uu.jpg

http://i43.tinypic.com/j5cxg7.jpg

【问题讨论】:

    标签: excel vba populate


    【解决方案1】:
    Sub test()
    
    Dim rng As Range
    
    Dim dblrow As Double
    
    'shtSearch,shtCoutn are sheet names.
    
      lastrow = shtSearch.Cells(Rows.Count, 1).End(xlUp).Row
    
      j = 0
    
    For i = 1 To lastrow
        If InStr(1, shtSearch.Cells(i, 1), "abcd", vbTextCompare) > 0 Then
        'Count the search
            j = j + 1
        End If
    Next
    
    Set scrRng = shtCount.Range("A:A")
    
    Set rng = scrRng.Find(What:="abcd", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False)
    
    dblrow = Mid(rng.Address, 4, Len(rng.Address) - 3)
    
    shtCount.Cells(dblrow, 2) = j
    
    End Sub
    

    您可以修改上述代码并用于其他条件。

    【讨论】:

      猜你喜欢
      • 2018-02-26
      • 1970-01-01
      • 1970-01-01
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-25
      相关资源
      最近更新 更多