We help IT Professionals succeed at work.
Get Started

Excel VBA Loop Compare

112 Views
Last Modified: 2016-02-11
We have a macro which creates a list of contracted projects from a two dimensional array.  A user then adds an "X" to a cell one column to the left of that list to indicate which ones are in progress.  As projects are completed, they fall of the list; as new contracts come in, they are added.  Our challenge is that the "X" doesn't move each time the macro regenerates the list (because it has been manually entered).

The macro-generated list is in range C4:Dx.  We have copied the current list (and "X" column) to a parallel set of cells (I4:Kx) before we regenerate it.

I need help with the IF statement within a Do While loop that would:
a) Find an exact value match (if one exists) between Cx and Jx (like a LOOKUP function)
b) If there is a match, write the corresponding value from Ix to Bx
c) If not, set the corresponding value in column B to ""

In the attached example we have two sheets; what it is (IS sheet) and what it should be (SHOULD sheet).  In the IS sheet, the original list was copied from B4:D11 to I4:K11 and a new list was generated into C4:D12.  Since the first three rows match, everything is fine for them.  However, the fourth and fifth entries in the new list didn't exist in the old list, so the value in the B column for those rows should be "".  In contrast, because the new list is longer, there should be a corresponding "X" in B12 due to the Augusta match.

Any help is greatly appreciated.
ExampleFile.xlsx
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE