How to add data to macro versus referencing cells - validate list

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
721
Office Version
  1. 2016
Platform
  1. Windows
My original macro is working fine using the following

VBA Code:
    Range("C1").Validation.Add Type:=xlValidateList, Formula1:="=Subjects!$A$1:$A$5"

What I would prefer is to have the data in Subjects!$A$1:$A$5 to be hard coded into the macro and not have to reference the previously mentioned. Is this possible?

The following is what is in A1:A5 and the line above will create a drop down menu based on the below.
Friday Before
1 Hour Email
Class Has Started
Removed
In-Person

I hope that's clear :), or clear as mud?

Thank you,
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
One way.
VBA Code:
ValidationList = "Friday Before,1 Hour Email,Class Has Started,Removed,In-Person"
Range("C1").Validation.Add Type:=xlValidateList, Formula1:=ValidationList
Where ValidationList is a string variable.
 
Upvote 0
Solution
One way.
VBA Code:
ValidationList = "Friday Before,1 Hour Email,Class Has Started,Removed,In-Person"
Range("C1").Validation.Add Type:=xlValidateList, Formula1:=ValidationList
Where ValidationList is a string variable.
That's fantastic, thank you for the assist.
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

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