Results 1 to 8 of 8

Macro to identify missing value and include in range

Threaded View

pedrofogao21 Macro to identify missing... 03-23-2012, 09:08 AM
arlu1201 Re: Macro to identify missing... 03-23-2012, 09:18 AM
pedrofogao21 Re: Macro to identify missing... 03-23-2012, 09:22 AM
nilem Re: Macro to identify missing... 03-23-2012, 09:38 AM
pedrofogao21 Re: Macro to identify missing... 03-23-2012, 09:45 AM
arlu1201 Re: Macro to identify missing... 03-23-2012, 09:40 AM
pedrofogao21 Re: Macro to identify missing... 03-23-2012, 09:43 AM
arlu1201 Re: Macro to identify missing... 03-23-2012, 09:46 AM
  1. #1
    Registered User
    Join Date
    02-28-2012
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    37

    Macro to identify missing value and include in range

    Hi guys,

    I hope one of you gents might be able to help with this small matter.

    If in Sheet1 column A I have the following entries:


    Black
    Blue
    Brown
    Yellow


    And in Sheet2 Column B I have


    Blue
    Brown

    I wanted a macro that would identify which values are in Sheet1 Column A, but not in Sheet 2 Column B (Black and Yellow), and include them in Column B, one cell after the last entry.

    I posted the question in another forum and got a code that would work only of the columns were in the same sheet. Maybe one of you guys might work on that and help me out!

    Thanks in advance!

    Sub SearchData() 
        Dim MyRgA As Range, MyRgB As Range 
        Dim F  As Range 
        Dim LastRow As Long 
         
        LastRow = Range("B" & Rows.Count).End(xlUp).Row 
        Set MyRgA = Range(Cells(1, "A"), Cells(Rows.Count, "A").End(xlUp)) 
        Set MyRgB = Range("B:B") 
        For Each F In MyRgA 
             
            If (Application.WorksheetFunction.CountIf(MyRgB, F.Value) = 0) Then 
                LastRow = LastRow + 1 
                Cells(LastRow + 1, "B") = F.Value 
            End If 
        Next F 
    End Sub
    Last edited by pedrofogao21; 03-23-2012 at 10:33 AM.

Thread Information

Users Browsing this Thread

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

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