Results 1 to 9 of 9

Macro to Search(Find) specific word from list, and copy a cell referenced from each

Threaded View

DadaaP Macro to Search(Find)... 10-28-2013, 01:13 PM
DadaaP Re: Macro to Search(Find)... 10-28-2013, 03:15 PM
AB33 Re: Macro to Search(Find)... 10-28-2013, 04:41 PM
DadaaP Re: Macro to Search(Find)... 10-28-2013, 04:59 PM
AB33 Re: Macro to Search(Find)... 10-28-2013, 05:14 PM
DadaaP Re: Macro to Search(Find)... 10-28-2013, 05:46 PM
AB33 Re: Macro to Search(Find)... 10-28-2013, 05:57 PM
DadaaP Re: Macro to Search(Find)... 10-30-2013, 12:07 PM
DadaaP Re: Macro to Search(Find)... 11-04-2013, 02:34 PM
  1. #8
    Registered User
    Join Date
    05-30-2013
    Location
    US
    MS-Off Ver
    2013
    Posts
    67

    Re: Macro to Search(Find) specific word from list, and copy a cell referenced from each

    AB33 I have gone and taken your code and think I learn more of the scripting dictionary. I wanted to try and create your program onto another sheet to do darn near the same thing. So I tweaked the column references inside the array to accommodate the different sheet.

    This looks like it would work, the biggest difference in this list is that the list now might not contain the name from the main list. The code I have from you that is altered:

    Sub GetRetainageAmt()
       Dim x, i As Long, k As Long  'Declarations
    
    
     With Worksheets("OnlyRetention")
        x = .Range("J1:R" & .Range("J" & .Rows.Count).End(xlUp).Row)
     End With
     
    With CreateObject("Scripting.Dictionary")
        .CompareMode = 1
        For i = 4 To UBound(x)
            If Len(x(i, 1)) Then
               If Not .exists(x(i, 1)) Then
                 ReDim Z(1 To 1)
                   Z(1) = x(i, 8)
                    .Item(x(i, 1)) = Z
               Else
                    Z = .Item(x(i, 1))
                    Z(1) = Z(1) + x(i, 8)
                   .Item(x(i, 1)) = Z
               End If
            End If
        Next i
            With Worksheets("Main")
               x = .Range("X1:Z" & .Range("X" & .Rows.Count).End(xlUp).Row)
            End With
     
      For i = 1 To UBound(x)
           If Len(x(i, 2)) Then
               If .exists(x(i, 2)) Then
                    k = k + 1
                    x(k, 2) = .Item(x(i, 2))(1)
               End If
           End If
      Next
    End With
           With Worksheets("Main")
              .Range("Z1:W" & .Rows.Count).ClearContents
              If k > 0 Then .Range("Z1").Resize(k, 1) = x
           End With
        
    End Sub
    Attached is a updated Test Excel File to view the new sheet that was added.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Macro for search specific word and input specific value
    By Toton6868 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-10-2013, 07:14 AM
  2. Macro to search sheet for certain criteria and copy specific data to cell
    By ThaGonz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-02-2012, 12:34 PM
  3. Replies: 13
    Last Post: 08-04-2011, 09:41 AM
  4. Replies: 1
    Last Post: 01-25-2011, 10:50 PM
  5. search for a specific word and copy the word and the preceeding words until a comma
    By DHANANJAY in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-31-2005, 09:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1