|
-
Sep 15th, 2005, 11:36 AM
#1
Thread Starter
Member
[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:
Dim Range1 As Range
Dim Range2 As Range
Dim Cell1 As Range
Dim Cell2 As Range
Set Range1 = Range("GL")
Set Range2 = Range("Stmt")
For Each Cell1 In Range1.Cells
For Each Cell2 In Range2.Cells
If Cell1 = Cell2 Then
Cell1.ClearContents
Cell2.ClearContents
End If
Next Cell2
Next Cell1
'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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|