Hello and thank you in advance for any help!
I am compiling a dataset from 2 databases. One of the databases exports a data field "A". The other exports a data field as the product of "A" and a payment rate. I am trying to have the final dataset only report "A", so I need to divide "A" out of the field that is the product of "A" and the payment rate.
The payment rate is based on 4 primary categories:
Region = North, South
Program = Solar, Wind, Hydro, Solar Thermal
Category = Residential, Small Business, Public, Agriculture
Step = 1,2,3,4,5,6,7,8,9
I have set up a table that has the Step in a column, and the other descriptors in the rows. I was able to create a nested If statement formula and copy/paste it down the column for some of the combinations, but am limited by the number of If statements. So, I am trying to use VBA to divide the value in column 12 (the product of "A" and the payment rate) by the payment rate to obtain "A", based on which combination of descriptors describes the project.
Below is a sample of the road I was trying to go down, without initial success. Again, any help is GREATLY appreciated!
Sub NewCap()
'
' NewCap Macro
'
FinalRow = Cells(Rows.Count, 4).End(xlUp).Row
For i = 4450 To FinalRow
Program = Cells(i, 4).Value
Category = Cells(i, 6).Value
Utility = Cells(i, 7).Value
If Utility = "North" Then
If Program = "Solar" Then
Select Case Category
Case "Residential"
Cells(i, 11).FormulaR1C1 = "If(ISNA(Vlookup(RC[-9],SchoolsPetitions!$O$5:$Z$13,6,False))=False,Vlookup(RC[-9],SchoolsPetitions!$O$5:$Z$13,6,False),RC[1]/Vlookup(RC[-8],MergeProcess!,2,False)"
Case "Small Business"
Cells(i, 11).FormulaR1C1 = "If(ISNA(Vlookup(RC[-9],SchoolsPetitions!$O$5:$Z$13,6,False))=False,Vlookup(RC[-9],SchoolsPetitions!$O$5:$Z$13,6,False),RC[1]/Vlookup(RC[-8],MergeProcess!,2,False)"
End Select
End If
End If
Next i
End Sub
Thanks, JM
Bookmarks