+ Reply to Thread
Results 1 to 4 of 4

If cells in range not in range then...

Hybrid View

3nduranc3 If cells in range not in... 12-12-2015, 09:48 AM
Richard Buttrey Re: If cells in range not in... 12-12-2015, 10:04 AM
3nduranc3 Re: If cells in range not in... 12-12-2015, 10:18 AM
:) Sixthsense :) Re: If cells in range not in... 12-12-2015, 10:10 AM
  1. #1
    Registered User
    Join Date
    04-15-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    36

    Question If cells in range not in range then...

    Hello,

    I would like to ask for your help on this topic. I want to make an updating procedure from 2 lists. 1 list is what i would expand, the other is what I will download and check for the new entries. So basically, I have a date range, and I would check each cell in the downloaded list, to see if it is already in my actual one. If not, then it should write it in the end. At the beginning I would try to accomplish this with 1 criteria, but aim is to make it happen from 2 criteria.

    So far I got:

    Sub monitoring()
        
    Dim lrow1, lrow2 As Long
    Dim c As Range
    Dim i As Long
    
    
    lrow1 = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
    lrow2 = Sheets("Elemzés").Range("A" & Rows.Count).End(xlUp).Row
    
    For Each c In Sheets("Data").Range("A2:A" & lrow1)
        If IsNumeric(Application.Match(c, Sheets("Elemzés").Range("A2:A" & lrow2), 0)) = False Then
            c.Offset(0, 1).Value = 0
            Sheets("Elemzés").Cells(lrow2 + 1, 1).Value = c
            Exit For
        End If
    Next c
        
    End Sub
    The problem is, that if I run the macro, it only makes this happen for 1 cell, not for each cell in the data range. So to freshen up the list I have to click it until all new entries are in one by one.

    And the second step would be that it should check a pair of 2 cells. So for each cell in "Data" Sheet, if cell1 value and (int the same row) cell2 value does not match in "Elemzés" sheet another cell1 value and (int the same row) cell2 value, then it should make a new entry to the "Elemzés" sheet, after the last cell.

    Does this make sense?

    Thanks in advance!

    Ambrus

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: If cells in range not in range then...

    Hi,

    Upload the workbook and manually add the results you expect. It may be possible to do this with normal functions and avoid VBA.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    04-15-2013
    Location
    Hungary
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: If cells in range not in range then...

    Hello,

    Here is a simplified version of the file. So the idea is, if Sheet "Data" A1,B1 (and then A2,B2 and so on..) can not be found in Sheet "Elemzés" as Ax, Dx, then add these after the last row in Sheet "Elemzés".

    Forumdata.xlsx

    Thank you in advance!

    Ambrus

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: If cells in range not in range then...

    Sub monitoring()
    Dim lrow1 As Long, lrow2 As Long, c As Range, i As Long
    
    lrow1 = Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row
    
    Application.ScreenUpdating = False
    
    With Sheets("Elemzés")
        lrow2 = .Range("A" & Rows.Count).End(xlUp).Row
        For Each c In Sheets("Data").Range("A2:A" & lrow1)
            If IsError(Application.Match(c, .Range("A2:A" & lrow2), 0)) Then
                lrow2 = .Range("A" & Rows.Count).End(xlUp).Row
                c.Offset(0, 1).Value = 0
                .Cells(lrow2 + 1, 1).Value = c
            End If
        Next c
    End With
    
    Application.ScreenUpdating = True
    
    End Sub


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

+ 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. I Filter range A9:AG300 using listbox(userform) hide all from range blank cells
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2014, 03:28 AM
  2. [SOLVED] Lock/Unlock range cells based on text value in other range cells
    By boboivan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-12-2014, 12:50 PM
  3. Count a Range of cells if another range of cells meets criteria
    By mjg060468 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-21-2013, 02:57 PM
  4. [SOLVED] Macro needed to clear cells in range based on value of cells in another range
    By msmith7113 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-05-2013, 12:32 AM
  5. [SOLVED] VBA Copy a range of cells values using the range of cells in a formula (which will change)
    By murtaep in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 06-05-2012, 07:59 AM
  6. Replies: 2
    Last Post: 05-31-2012, 05:37 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