简体   繁体   中英

How to add Data Validation in a Cell using VBScript

Hope you are all doing well.

I am trying to add Data Validation in an Excel Cell using VBScript but I can't figure the correct syntax. I can do it in VBA, it is not a problem, but I need to do it in VBScript. I just need to Add Validation with Values: "Yes", "No" into the cell.

Relevant code:

Dim xlValidateList

xlValidateList = 3

For s = 2 to sheetCount
  For r = 2 to sourceTotalRows
    xlBookSource.Sheets(s).Cells(r,23).Validation.Add xlValidateList, "Yes,No"
  Next
Next

Thanks in advance for any help.

Assuming the smart quotes are a typo, you have the formula as the wrong argument:

xlBookSource.Sheets(s).Cells(r,23).Validation.Add xlValidateList, , , "Yes,No"

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