I wanted to create a drop down list from data in Sheet2. I have tried the following codes but the outcome seems to be incorrect. Instead of the data in Sheet2 listed in the drop down list, the drop down list contained the data from Sheet1 (which is my destination sheet).
Also, I would like to have the drop down list on certain cells where I have information on the cells before, i.e. the drop down list should be in Column F of Sheet1 where there is information on Column E of Sheet1 and repeat until the end of the list.
Herewith attached is the file I am working on here
You create a validation list from ANOTHER WORKSHEET give a range name to that validation list(in sheet2)
and use that as the formula
I tried to modify your macro without disturbing except changing one or two lines
I have given range name as "rangename". you can change it in the macro
If necessary tweak it little more.
Dim x As Long, y As Long
Dim objCell As Range
Dim objDataRangeStart As Range
Dim objDataRangeEnd As Range
Dim rangename As String
' >> Set The Range For Valid Data
Set wsSourceList = Sheets("Sheet2")
Set wsDestList = Sheets("Sheet1")
Set objDataRangeStart = wsSourceList.Cells(1, 2) 'Start range for dropdown list entries
Set objDataRangeEnd = wsSourceList.Cells(6, 2) 'End range for dropdown list entries
Range(objDataRangeStart, objdatarangaeend).Name = "rangename"
' >> Set Validation On Required Cell
'Set objCell = wsDestList.Cells(8, 4) 'Location of the dropdown list
x = 4
y = 6
Set objCell = wsDestList.Cells(x, y) 'Location of the dropdown list
'.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=" & objDataRangeStart.Address & ":" & objDataRangeEnd.Address
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
.IgnoreBlank = True
.InCellDropdown = True
.ErrorTitle = "Warning"
.ErrorMessage = "Please select a value from the list available in the selected cell."
.ShowError = True
x = x + 1
'y = y + 1
Loop Until x = 51
Thanks to venkat1926
for this tip.
Published by deri58
Latest update on October 3, 2012 at 04:28 AM by deri58.