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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,111
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Why VBA ?
formula in column O
Code:
=IF(J1="ATO","Automated",IF(AND(J1="PRD",L1="waiting"),"Manual",""))

drag down as required
 
Last edited:

KMJM2019

New Member
Joined
Jan 2, 2019
Messages
10
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!!
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,111
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
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:

Watch MrExcel Video

Forum statistics

Threads
1,129,321
Messages
5,635,570
Members
416,865
Latest member
vipett

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
Top