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

288enzo

Well-known Member
Joined
Feb 8, 2009
Messages
727
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

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

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