Best way to clean up VBA list of re-occurring formulas

mssbass

Active Member
Joined
Nov 14, 2002
Messages
253
Platform
  1. Windows
Is there a better way to loop this code through these formulas?

wsdp.Range("X2:X" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=IsReferralComplete"
wsdp.Range("Y2:Y" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=Staffed"
wsdp.Range("Z2:Z" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=MSOC"
wsdp.Range("AA2:AA" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=MSOCReportedEOD"
wsdp.Range("AB2:AB" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=ApprovedASOCDate"
wsdp.Range("AC2:AC" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=ReStaffed"
wsdp.Range("AE2:AE" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=Category"
wsdp.Range("AF2:AF" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=CompleteHTSEmail"
wsdp.Range("AG2:AG" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=AddtoCart"
wsdp.Range("AH2:AH" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=CaseWorkedPerDLP"
wsdp.Range("AI2:AI" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=DLPProcessMissed"
wsdp.Range("AJ2:AJ" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=FLBlueProcessMissed"
wsdp.Range("AL2:AL" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=CaseWorkedPerDLP"
wsdp.Range("AN2:AN" & Lrowwsdp).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=EmpCoaching"
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
How about like
VBA Code:
Dim Ary As Variant
Dim i As Long
Ary = Array("X", "=IsReferralComplete", "Y", "=Staffed", "Z", "=MSOC")

For i = LBound(Ary) To UBound(Ary) Step 2
   With wsdp.Cells(2, Ary(i)).Resize(Lrowwsdp).Validation
   .Delete
   .Add xlValidateList, xlValidAlertStop, , Ary(i + 1)
   End With
Next i
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,480
Messages
6,125,049
Members
449,206
Latest member
Healthydogs

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