VBA dynamic dropdownlist

mkh12ab

New Member
Joined
Apr 9, 2021
Messages
15
Office Version
  1. 2019
Platform
  1. Windows
Hello all,

previously i have been getting alot of help with getting my dynamic dropdown range to work.
the special thing about this dropdown is that i create a dropdown in my VBA which can refers to deffirent columns.
the header will allways be written in row 2.
the data for the dropdown should be in the active column from row 3 and .End(xlDown)

issue at the moment is that my dropdown only show the data from my header (Row 2) which i have marked with red text
i believe that the range with yellow text is the answer to my troubles??

any help will be highly appriciated

so far it looks like

Set wb = ActiveWorkbook
Set ws1 = Ark3
Set ws2 = Ark2
Set ws3 = Ark4

' Create named range for validation list.
eRow = ws1.Cells(3, ring + 2).End(xlDown).Row
Set rnglist = ws1.Range(ws1.Cells(3, ring + 2), ws1.Cells(eRow, ring + 2))
wb.Names.Add Name:=dropdownTekst, RefersTo:=rnglist

'indsæt columns for Projekt reference
ws3.Visible = xlSheetVisible
ws3.Columns(ring + 3).Insert
ws3.Range("C1").Offset(0, ring) = dropdownTekst

ws3.Range("C1").Offset(1, ring).Validation.Delete
ws3.Range("C1").Offset(1, ring).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:=dropdownTekst
ws3.Visible = xlSheetHidden
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,091
Office Version
  1. 2016
Platform
  1. Windows
ws3.Range("C1").Offset(1, ring).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=" & dropdownTekst
 
Solution

mkh12ab

New Member
Joined
Apr 9, 2021
Messages
15
Office Version
  1. 2019
Platform
  1. Windows
ws3.Range("C1").Offset(1, ring).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="=" & dropdownTekst
Thanks alot :D works perfectly
 

Watch MrExcel Video

Forum statistics

Threads
1,129,930
Messages
5,639,051
Members
417,066
Latest member
rhenman

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
Top