Data Validation

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,926
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
This code creates a data validation list for the cell A1:


Code:
Dim i, j


    For j = 1 To 10
    
        i = i & "," & j
        
    Next j
    
    With Sheet1.Range("A1")
    
        With .Validation
        
            .Delete
            .Add Type:=xlValidateList, _
                 AlertStyle:=xlValidAlertStop, _
                 Operator:=xlBetween, _
                 Formula1:=i
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = vbNullString
            .ErrorTitle = vbNullString
            .InputMessage = vbNullString
            .ErrorMessage = vbNullString
            .ShowInput = True
            .ShowError = True
        
        End With
           
    End With


However if the loop goes to 100, saving the file then opening it reveals an error.


Code:
Excel found unreadable content in myfile.xlsm. Do you want to recover the contents of the workbook? If you trust the source of this workbook, click Yes.


I think the reason is there is a 250 character limit to a data validation cell.


But if I created the DV where it links to a source, for example if the numbers 1 to 100 were on Sheet2 and I point the DV to that column of data, it seems fine.


Why is that?


Does anyone know if this "limit" problem applies to ActiveX Comboboxes?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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