Forum Discussion
YannickDVTC
Aug 29, 2022Copper Contributor
Data Validation Cell Length with error message
Hi, I am currently creating a template for suppliers where they have to fill in product information. In order to avoid receiving bad quality data, I would like to create a macro that the suppl...
- Aug 29, 2022
Sub data() Dim i As Long Dim j As Long For i = 21 To 7100 For j = 24 To 26 If Len(Cells(i, j)) > 32 Then MsgBox ("Error in column:" & j & "row:" & i) Else End If Next j Next i End SubYou can try this code. In the attached file you can click the button in cell V2 to run the macro. If a cell is longer than 32 digits an error message shows the row and column number of that cell.
OliverScheurich
Aug 29, 2022Gold Contributor
Sub data()
Dim i As Long
Dim j As Long
For i = 21 To 7100
For j = 24 To 26
If Len(Cells(i, j)) > 32 Then
MsgBox ("Error in column:" & j & "row:" & i)
Else
End If
Next j
Next i
End SubYou can try this code. In the attached file you can click the button in cell V2 to run the macro. If a cell is longer than 32 digits an error message shows the row and column number of that cell.
YannickDVTC
Aug 30, 2022Copper Contributor
Thank you very much for your help! Saved my day!