I am writing a macro with multiple sheet and multiple validations. One of the requirement is to limit 1000 characters in range of cells. You are allowed to enter any character. I am achieving it through regex. My code reads as -----> Public Const QUAL_REGEX = "^.{1,1000}$"
I also have an error handling if the above condition s not met. For e.g. if the length exceeds 1000 characters. This works fine. However, it gives an error when there is line break or enter character. I want to allow users to be able to use enter or line breaks. How can I achieve using REGEX.
IF Len(cell.Value) > 1000 Then^(?:(?! *, *\^)[\s\S])*Further `(?! *, *\^) # negative lookahead that fails the match if next pattern is 0 or more spaces # followed by a comma and optional spaces and literal ^ [\s\S] # matches any character including newlines. As explained in the SO Link<stackoverflow.com/questions/30785808/…>