INSERT FORMULAS BASED ON CELL VALUE

I need VBA code to have formulas inserted in column R & Q based on the values in other columns.

Where column A is in { "PO","SO","E2AM","E2","ESP"}
Where column A is in { "HD", "GR"}
Where column A is in ("MWT"}  
Where column A is in {"IE", "IP", "IEF","IPF"} AND column K is in {"PR"}
Where column A is in {"IE", "IP", "IEF","IPF"} AND column H is in {"PR"}
Where column A is in {"IE", "IP", "IEF","IPF"} AND column J is in {"US"} AND column M is NOT IN {"US"}
Where column A is in {"IE", "IP", "IEF","IPF"} AND column M is in {"US"} AND column J is NOT IN {"US"}

I am attaching a data set and separate list of formulas related to the conditions.
I hope this will keep it simple!?
Can anyone help? Thank!! :)
SAMPLE-FORMULAS-DATA.xlsx
FORMULAS-FOR-RE-RATE.docx
Euro5Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wilder1626Commented:
Hi see that you have a lot of IF statement. It would take long to go over all of them, so i will give you something to start.
Is this what you are looking for?
If the answer is yes, you can continue to add all your If statements.

Dim c As Long, LR As Long
LR = Range("A2").End(xlDown).Row
For c = LR To 2 Step -1

'If Column A = PO
    If Cells(c, "A") = "PO" Then
        If Cells(c, "U") > 150 Then Cells(c, "Q") = "POHW"
        If Cells(c, "B") >= "Fedex Letter" Then Cells(c, "Q") = "POL"
        If Cells(c, "B") >= "Fedex Pak" Then Cells(c, "Q") = "POP"
     End If
   
'If Column A = E2
  If Cells(c, "A") = "E2" Then
       
     End If
'...........
Next

Open in new window


if result
0
Euro5Author Commented:
YES, thanks!
0
Wilder1626Commented:
Are you ok to adjust all If statement on your own based on the above macro i gave you?
0
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Euro5Author Commented:
Trying to see if I can get it to work... how do I do an AND?
0
Wilder1626Commented:
If i take the below example

You are looking after column A where you have the value PO, if it see PO then it will look at the second statement that equals to AND. Ex: If the column U > 150 column Q will equal POHW. If the column B = Fedex Letter, then column Q = POL, etc.

 If Cells(c, "A") = "PO" Then 
        If Cells(c, "U") > 150 Then Cells(c, "Q") = "POHW"
        If Cells(c, "B") >= "Fedex Letter" Then Cells(c, "Q") = "POL"
        If Cells(c, "B") >= "Fedex Pak" Then Cells(c, "Q") = "POP"
     End If

Open in new window


Above macro could also be like below and do the same results. You would also see your AND statement:
 If Cells(c, "A") = "PO" And Cells(c, "U") > 150 Then Cells(c, "Q") = "POHW"
 If Cells(c, "A") = "PO" And Cells(c, "B") >= "Fedex Letter" Then Cells(c, "Q") = "POL"
 If Cells(c, "A") = "PO" And Cells(c, "B") >= "Fedex Pak" Then Cells(c, "Q") = "POP"
 '........... ETC.......

Open in new window


at the end, the code could be something like this:
Dim c As Long, LR As Long
LR = Range("A2").End(xlDown).Row
For c = LR To 2 Step -1

 If Cells(c, "A") = "PO" And Cells(c, "U") > 150 Then Cells(c, "Q") = "POHW"
 If Cells(c, "A") = "PO" And Cells(c, "B") >= "Fedex Letter" Then Cells(c, "Q") = "POL"
 If Cells(c, "A") = "PO" And Cells(c, "B") >= "Fedex Pak" Then Cells(c, "Q") = "POP"
    

'...........

Next

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Euro5Author Commented:
Got it!
Working though - think this is working perfectly!
0
Wilder1626Commented:
This is good news. :)

let me know your final results!!!!!!!
0
Euro5Author Commented:
Excellent thanks so much!
0
Wilder1626Commented:
i'm glad i was able to help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.