VBA code help to populate text in a specific column based on another column condition

KMJM2019

New Member
Joined
Jan 2, 2019
Messages
10
if any row in column J that = ATO then I need every row in column O to populate "Automated". Also if any row in column J = PRD and any row in column L = "waiting" then I need every row in column O that satisfies both criteria to = "Manual".
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Why VBA ?
formula in column O
Code:
=IF(J1="ATO","Automated",IF(AND(J1="PRD",L1="waiting"),"Manual",""))

drag down as required
 
Last edited:
Upvote 0
Hi Michael M,

Thank you for your response. I am looking for a VBA code because there is a report that I run daily, and the amount of data differs. I am tasked with automating this and have already coded a lot of data based on similar conditions. Since the rows change I need to hard code a VBA formula into a macro to auto populate this. Can I do that with the IF statement or would I have to copy and paste this every time? My goal is to set a formula so I run the macro and do not have to manually enter anything. Any help with a VBA code would be very much appreciated.

Thank you!!
 
Upvote 0
Ok

Code:
Sub MM2()
Dim lr As Long
lr = Cells(Rows.Count, "J").End(xlUp).Row
Range("O2:O" & lr).Formula = "=IF(J2=""ATO"",""Automated"",IF(AND(J2=""PRD"",L2=""waiting""),""Manual"",""""))"
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top