ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

½Ð°Ý¸ê®Æ¦X¨Ö­pºâÁ`©M­n¦p¦ó¼g?

½Ð°Ý¸ê®Æ¦X¨Ö­pºâÁ`©M­n¦p¦ó¼g?

ÀɮצpªþÀÉ

»¡©ú¡G
¤ñ¦pcÀɮתºÁ`©MÄæ¦ì­n¥h­pºâa©MbÀɮתº¸ê®Æ¤¤Àx¦s®æÁ`¼Æ¡A¦ýaÀɮפ¤ªº"d"©M"e"¸ê®Æª½±µ»PbÀɮפ¤ªº"f"¸ê®Æ¤@°_­pºâ¦¨"f"¸ê®ÆªºÁ`©M¡A³o­Ó¥¨¶°­n¦p¦ó¼g¡H

My Documents.rar (16.76 KB)

§A¦n
½Ð¸Õ¸Õ¦p¤U
Sub aa()

    '½Ð¥ý¥Ñ¤u¨ã³]©wMicrosoft Scripting Rungtime
   
    Dim mSht As Worksheet
    Dim mDic As Scripting.Dictionary
    Dim mKey, mItem
    Dim mArr
    Dim mRng As Range, E As Range
    Dim s%, s1%
   
   
    Set mDic = CreateObject("scripting.dictionary")
    mArr = Array("a", "b")
   
    For i = 0 To 1
        With Workbooks.Open(ThisWorkbook.Path & "\" & mArr(i) & ".xlsx")
            With .Sheets(1)
                Set mRng = .Range("i2:i" & .[i65536].End(xlUp).Row)
            End With
               
                For Each E In mRng
                    If mDic.Exists(E.Value) = False Then
                        mDic(E.Value) = 1
                    Else
                        mDic(E.Value) = mDic(E.Value) + 1
                    End If
                    
                Next
               
                mKey = mDic.Keys
                mItem = mDic.Items
               
            .Close
        End With
    Next
   
    For i = 0 To mDic.Count - 1
        If mKey(i) = "d" Then
            s = mItem(i)
        End If
        
        If mKey(i) = "e" Then
            s1 = mItem(i)
        End If
        
    Next
      
    For i = 0 To mDic.Count - 1
        
        If mKey(i) = "f" Then
            mItem(i) = mItem(i) + s + s1
        End If
    Next
   
    'Set mRng = Range("b3:b" & [b65536].End(xlUp).Row)     '
    '
    'For Each E In mRng                     'ª©¥D¤j¤j¬O§_¥iÀ°¤p§Ì¸Ñ´b¬°¦ó¦¹»yªkµLªk¥¿½T¨ú¥Xdictionaryªºitems­È©O¡H
    '    E.Offset(, 1) = mDic(E.Value)      '¦¹³¡¥÷¦³°ÝÃD
    'Next
   
    For i = 0 To mDic.Count - 1
        Set mRng = Columns("b").Find(mKey(i), lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlNext)
        If Not mRng Is Nothing Then
            mRng.Offset(, 1) = mItem(i)
        End If
        
    Next
        
End Sub

TOP

¦^´_ 1# zaq370
  1. Sub Ex() 'A,B¨âÀɤw¶}±Ò
  2.     Dim A_Rng As Range, B_Rng As Range, C_Rng As Range, i As Integer
  3.     With Workbooks("A.XLSX").Sheets(1)
  4.         Set A_Rng = .Range("i2", .[i2].End(xlDown))
  5.     End With
  6.     With Workbooks("B.XLSX").Sheets(1)
  7.         Set B_Rng = .Range("i2", .[i2].End(xlDown))
  8.     End With
  9.     With Workbooks("C.XLSX").Sheets(1)
  10.         Set C_Rng = .Range("B3", .[B3].End(xlDown))
  11.     End With
  12.     C_Rng.Offset(, 1) = ""
  13.     For i = 1 To C_Rng.Count
  14.         If i < C_Rng.Count Then
  15.             C_Rng(i, 2) = Application.CountIf(A_Rng, C_Rng(i)) + Application.CountIf(B_Rng, C_Rng(i))
  16.         Else
  17.             C_Rng(i, 2) = A_Rng.Count + B_Rng.Count - Application.Sum(C_Rng.Offset(, 1))
  18.         End If
  19.     Next
  20.     Set A_Rng = Nothing
  21.     Set B_Rng = Nothing
  22.     Set C_Rng = Nothing
  23. End Sub
½Æ»s¥N½X

TOP

¦^´_ 3# GBKEE


    ·PÁ¤j¤jªºÀ°¦£¡A°ÝÃD¤w¸Ñ¨M¤F¡I¡I

TOP

        ÀR«ä¦Û¦b : ¤Hªº¤ß¦a¬O¤@²¥¥Ð¡A¤g¦a¨S¦³¼½¤U¦nºØ¤l¡A¤]ªø¤£¥X¦nªºªG¹ê¡C -
ªð¦^¦Cªí ¤W¤@¥DÃD