Is there a macro or anyway I can get data validation lists into a sheet?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I've inherated a document and one page is loads of dropdown quetions,

now the person has set up the data validation for evry one by typing into the data validation box the names,
is there any way I can export this into a sheet?

so for example J7 = Tom Jones,Chris Prat,Courtney Cox,Wayne Ker
any way i can pull this out into a sheet ?
thanks
Tony
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
No. if the list is hardcoded into validation list separated by commas . However if the list is being selected from range then you can
 
Upvote 0
Try:
VBA Code:
Range("K7") = Range("J7").Validation.Formula1
 
Upvote 0
Akuini that worked perfectly,
now to really save me time
can we do this to an entire document?
 
Upvote 0
1. In what ranges are the data validation located?
2. Do you want to return each data validation list to the next cell (as my code does)?
 
Upvote 0
can we do this to an entire document?
Perhaps like this (only lists results for cells with Data Validation type is Allow: List)

VBA Code:
Sub DetDV()
  Dim ws As Worksheet
  Dim a As Variant
  Dim i As Long, k As Long
  Dim c As Range, DVCells As Range
  Dim wsName As String
  
  Worksheets.Add(Before:=Sheets(1)).Name = "DV Lists"
  ReDim a(1 To Rows.Count, 1 To 3)
  For i = 2 To Sheets.Count
    With Sheets(i)
      Set DVCells = Nothing
      On Error Resume Next
      Set DVCells = .Cells.SpecialCells(xlCellTypeAllValidation)
      On Error GoTo 0
      If Not DVCells Is Nothing Then
        wsName = .Name
        For Each c In DVCells
          If c.Validation.Type = 3 Then
            k = k + 1
            a(k, 1) = wsName: a(k, 2) = c.Address(0, 0): a(k, 3) = c.Validation.Formula1
          End If
        Next c
      End If
    End With
  Next i
  With Sheets(1).Range("A2:C2").Resize(k)
    .Rows(0).Value = Array("Sheet", "Cell", "DV List")
    .Value = a
    .EntireColumn.AutoFit
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

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