VBA - Change value in column J based on value in column H

I need to put "US" in each row for column H where J = "PR" &
put "US" in each row for column M where K = "PR"

I do not know how long the list will be, but need to use Column A to define the "last row" as there may be blanks in other columns.

Thanks!
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.

Roy CoxGroup Finance ManagerCommented:
Can you attach an example workbook
Euro5Author Commented:
ProfessorJimJamMicrosoft Excel ExpertCommented:
Vba or formula?
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

ProfessorJimJamMicrosoft Excel ExpertCommented:
please find attached formula solution
prsample.xlsx
MacroShadowCommented:
Here's a VBA solution:
Sub EE_28681875()

    Dim rCell As Range
    Dim rRng As Range

    Set rRng = Sheet1.Range("A1:A" & Sheet1.Cells(Sheet1.Rows.Count, "A").End(xlUp).Row)

    For Each rCell In rRng.Cells
        If Range("J" & rCell.Row).Value = "PR" Then Range("H" & rCell.Row).Value = "US"
        If Range("K" & rCell.Row).Value = "PR" Then Range("M" & rCell.Row).Value = "US"
    Next rCell

End Sub

Open in new window

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
ProfessorJimJamMicrosoft Excel ExpertCommented:
and vba

Sub test()
Dim C As Range
Dim IR As Long
For IR = 2 To Cells(Rows.Count, "A").End(xlUp).Row
If Cells(IR, 10).Value = "PR" Then
Cells(IR, 8).Value = "US"
If Cells(IR, 11).Value = "PR" Then
Cells(IR, 13).Value = "US"
End If
End If
Next
End Sub

Open in new window

Euro5Author Commented:
Thanks!
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.