+ Reply to Thread
Results 1 to 2 of 2

VBA code to Remove duplicates and apply vlookup and sumif

Hybrid View

  1. #1
    Valued Forum Contributor mangesh.mehendale's Avatar
    Join Date
    06-04-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    510

    VBA code to Remove duplicates and apply vlookup and sumif

    Hello..
    There are party names from column B11 (blank cell in Column B) and party codes are in other sheet "TIN Master" .. I want to copy Col B to O11 remove duplicates and apply vlookup in col. P11 with party codes... IFERROR(VLOOKUP(N11,'TIN Master'!$A$2:$B$4,2,FALSE),"NA")
    And amount in col. G ... want to apply Sumif to Col. O4 SUMIF($B$11:$G$16,$N11,$G$11:$G$16)

    Right now I am filling down the formula from P10 and Q10
    Last edited by mangesh.mehendale; 07-09-2015 at 12:12 AM. Reason: detailed explanation

  2. #2
    Valued Forum Contributor mangesh.mehendale's Avatar
    Join Date
    06-04-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    510

    Re: VBA code to Remove duplicates and apply vlookup and sumif

    Okay resolved by me.......

    Sub Macro1()
        Dim TINLastRow As Long
        Dim TDLastRow As Long
        Dim TIN As Worksheet
        Dim TD As Worksheet
        Dim rng As Long
        Set TIN = Worksheets("TIN Master")
        Set TD = Worksheets("Tally Data")
        TD.Select
        If Range("B11") = Empty Or Range("G11") = Empty Or Range("H11") = Empty Then
           MsgBox ("Fill Mandatory Feilds!")
         Exit Sub
        End If
        If ActiveSheet.Range("B11").Value = "" Then Exit Sub
        Range("$N$11:$R$5000").Select
        Selection.ClearContents
        Range("$B$11:$B$5010").Select
        Selection.Copy
        Range("O11").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False    
        With TD
            rng = Range("O" & Rows.Count).End(xlUp).Row
        End With
        Range("O11:O" & rng).Select
        Selection.RemoveDuplicates Columns:=1, Header:=xlNo
        With TIN
        TINLastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
        End With
        With TD
            TDLastRow = .Cells(.Rows.Count, "O").End(xlUp).Row
        .Range("P11:P" & TDLastRow).Formula = _
        "=VLOOKUP(O11,'" & "TIN Master" & "'!$B$10:$C$" & TINLastRow & ",2,0)"
        .Range("Q11:Q" & TDLastRow).Formula = _
        "=ROUND(SUMIF($B$11:$H$5010,$O11,G$11:G$5010),0)"
        .Range("R11:R" & TDLastRow).Formula = _
        "=ROUND(SUMIF($B$11:$H$5010,$O11,G$11:G$5010),0)"
        End With    
    End Sub
    Last edited by mangesh.mehendale; 07-14-2015 at 05:42 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Remove Duplicates code help
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2014, 01:15 PM
  2. Formula or VBA code to remove duplicates
    By james19 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-11-2014, 05:15 AM
  3. Need VBA code to remove entries if there are duplicates (remove them totally)
    By BrandonFromSingapore in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2012, 12:50 AM
  4. Remove Duplicates Code
    By Winon in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-18-2011, 04:36 PM
  5. Remove duplicates, then sumif, with only formula
    By pmhabo in forum Excel General
    Replies: 4
    Last Post: 07-13-2011, 10:23 AM

Tags for this Thread

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