Excel formula to VBA code

kc999

New Member
Joined
Jun 17, 2014
Messages
3
I am trying to understand how to write the following code in VBA rather than use the following formula which does work.

Column A formula:
=IF(AND(F2="Red\Recurring",B2="No"),"delete row",IF(AND(F2="Blue\Recurring",B2="No"),"delete row",IF(AND(F2="Yellow\Recurring",B2="No"),"delete row","ok")))

Column B is a formula too, which I am sure could become part of a more complicated piece of VBA code.
=IF(AND($E2="Yellow",$K2="orange)"),"Important",IF(AND($E2="Blue",$K2=""),"Important",IF(AND($E2="Red",$K2=""),"Important","No")))


The table I am using looks like this.
KeepImportantWorkstreamCustomerTeamPath
okImportantRedSales and Trade SystemsRedRed\Recurring
okNoIntegration Account PlanningPromo listIntegration Account PlanningIntegration Account Planning\Iteration 13
okImportantRedEnterprise WarehousingRedRed\Recurring
okImportantRedEnterprise WarehousingRedRed\Recurring
okImportantRedFinancial Accounting ServicesRedRed\Recurring
okImportantRedSales and Trade SystemsRedRed\Recurring
delete rowNoIntegration IntegrationInterfacesIntegrationRed\Recurring
okNoIntegration Order to Cash CoreMaster Data GatheringIntegrationIntegration\Graveyard
okImportantRedCustomer Order ManagementRedRed\Recurring
okImportantRedIT Process GovernanceBlueBlue\Recurring
okNoIntegration Account PlanningPlanning UOMIntegrationIntegration Account Planning\Iteration 13
okNoOffice 365Site Owner Training (Admin Topics)Office 365\SharePoint - OnlineOffice 365\Iteration 2
okNoInterim Reporting DatabaseSKU: Leading zeros causing SKU to exist in multiple formatsInterim Reporting Database\Master DataInterim Reporting Database\Iteration 9
okImportantBlueApplicationsBlueBlue\Recurring
delete rowNoYellowAP & TreasuryYellowYellow\Recurring
okImportantPrepCutover/Testing/SecuirtyRedPrep\Iteration 11


<tbody>
</tbody>
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
This works in the scenario you presented
Code:
Option Explicit


Sub kc()
Dim lr As Long
lr = Range("C" & Rows.Count).End(xlUp).Row
Dim i As Long


Application.ScreenUpdating = False
For i = 2 To lr
Range("A" & i).FormulaR1C1 = "=IF(AND(RC[5]=""Red\Recurring"",RC[1]=""No""),""delete row"",IF(AND(RC[5]=""Blue\Recurring"",RC[1]=""No""),""delete row"",IF(AND(RC[5]=""Yellow\Recurring"",RC[1]=""No""),""delete row"",""ok"")))"
Range("B" & i).FormulaR1C1 = "=IF(AND(RC5=""Yellow"",RC11=""orange""),""Important"",IF(AND(RC5=""Blue"",RC11=""""),""Important"",IF(AND(RC5=""Red"",RC11=""""),""Important"",""No"")))"
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks for the quick reply. I can get that to do the evaluations, but it does not delete the rows based on formula A. That's my ultimate goal.
 
Upvote 0

Forum statistics

Threads
1,215,065
Messages
6,122,945
Members
449,095
Latest member
nmaske

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