VBA replace column a based on cells

I would like to have a code that would look at
sheet "Enter Data" cells D6 & G6 and if they are both populated...

Change all cells in sheet "Reduced_Data" COLUMN A that = D6 to what is in G6.

the sample is attached.
Rerate-v5.0.xlsm
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.

Saurabh Singh TeotiaCommented:
So if i understand this correctly..You want to to change all values of Reduced_data sheet from E2 to GR... Is this what you are looking for??

Saurabh...
Martin LissOlder than dirtCommented:
Try this.

Sub UpdateReducedData()
Dim lngLastRow As Long
Dim lngRow As Long

With Sheets("Reduced_Data")
    lngLastRow = .Range("A1048576").End(xlUp).Row
    For lngRow = 2 To lngLastRow
        If .Cells(lngRow, 1) = Sheets("Enter Data").Range("D6") Then
            .Cells(lngRow, 1) = Sheets("Enter Data").Range("G6")
        End If
    Next

End With
End Sub

Open in new window


BTW IMO you have too many modules. If I were you I would move the contents of all the subs to one or two modules.

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:
Perfect!
Yes, you are right of course.
I thought I would be more organized keeping different modules, but it actually got out of control.
Martin LissOlder than dirtCommented:
The harder job would be to go through the module(s) and delete what you don't need, like the Sub x that I added while I was working on of your questions.
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.