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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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,213,567
Messages
6,114,342
Members
448,570
Latest member
rik81h

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