Results 1 to 4 of 4

Thread: [RESOLVED] Compare Range Values (Continued)

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    61

    Resolved [RESOLVED] Compare Range Values (Continued)

    The answer that I have received to my last inquiry regarding this topic was great and useful. However, now I have an idea that may be too complicated to make a reality without having to utilize hours of a professional programmer’s time. On the other hand, I may get lucky and you guys may know a simple way to do this. Like yesterday's question I have two ranges that vary in cell number. I want to compare each cell’s value in Range1 with cells’ value in Range2. Yesterday, I asked for each cell’s value to be compared for equality (see below); this is a long jump, but this time I would like VB to compare each cell’s value of range1 to two cells’ values in range2 who’s some equals the value of the cell in range1.

    So, I imagine that it would work by taking cell 1 in Range1 and comparing it to the sum of cells 1 and 2 in Range2; If the three cells’ values do not equal than it would start over. It would take cell 1 in Range1 and this time compare it to cells 1 and 3 in Range2, and so on, until all combinations were tested; after which, it would move on to cell 2 in Range1 and start the process over.

    I don’t expect anyone to know the actual code to this, but if I could get going in the correct direction that would be great.

    VB Code:
    1. Dim Range1 As Range
    2.     Dim Range2 As Range
    3.     Dim Cell1 As Range
    4.     Dim Cell2 As Range
    5.    
    6.     Set Range1 = Range("GL")
    7.     Set Range2 = Range("Stmt")
    8.    
    9.     For Each Cell1 In Range1.Cells
    10.         For Each Cell2 In Range2.Cells
    11.             If Cell1 = Cell2 Then
    12.                 Cell1.ClearContents
    13.                 Cell2.ClearContents
    14.             End If
    15.         Next Cell2
    16.     Next Cell1
    17. 'Written by DKenny adapted by Botillier
    Last edited by Botillier; Sep 15th, 2005 at 11:56 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width