PDA

View Full Version : Build new Nested Loop in VBA



nirvehex
02-09-2016, 12:25 PM
First off I would like to let anyone know that this project is a continuation of some code that I was previously helped with in http://www.vbaexpress.com/forum/showthread.php?55005-Nested-Loop-in-VBA. The last thread was code that was built up to the point as to where it is now.

What was made so far thanks to p45cal in this forum works perfectly. I'm now trying to extend the code to do more.

I need to add or build in the following cases. I'm not sure if they would be combined with the other cases or written as separate cases entirely, but I was hoping you could help me with the code some more :)


What I'm trying to do is the following:


1. For each row the "Recommendations" tab, where column CL = "yes" and column CV = "Home", and for any like SID on the "Services Export Raw" tab and only on the "Services Export Raw" tab rows where ServiceType (col. T) = "PPP" and OccurenceType (col. V) = "SCH":


Then in column CS on the "Services Export Raw" tab put a "1" and in column CT, put something like the other vlookup formulas:



.Cells(lRowToCopy + 1, "CT").Formula = "=VLOOKUP([@SID],Recommendations!E$3:DH$" & LstRw & ",108,)"


2. For each row on the "Recommendations" tab, where column CL = "yes" and column CV = "TP", and for any like SID on the "Services Export Raw" tab and only on the "Services Export Raw" tab where ServiceType (col. T) = "PPP" and OccurenceType (col. V) = "SCH":


Then in column CS on the "Services Export Raw" tab put a "0"


I've attached the Demo file. If anyone could lend a hand I'd greatly appreciate it! And thank you again to p45cal for the code he already wrote! Let me know if you have any questions regarding my explanation :)

Additionally, SamT from the last thread commented that I should replace my static worksheet formulas with lookups. If anyone can help me with that too, that would be great!

Thanks all!