简体   繁体   中英

How to check if a Cell contains a dropdown list with vba

I'm working on a VBA Scribt, that automatlically fills a large Excle with dummy data for testing reasons. Therefore i traverse all used cells and check theyr NumberFormat. The Excel also contains dropdown lists.

Is there any function that can find/ identify such a list and automatically select a random value?

Thanks!

Here is one way to check a cell for DataValidation

Sub IsIt()
    On Error GoTo trap
    MsgBox ActiveCell.Validation.Formula1
    On Error GoTo 0
    Exit Sub
trap:
    MsgBox "no data validation"
    On Error GoTo 0
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM