Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with text length of cells
Can someone help me modify this code to Allow
Operator:=xlEqual, Formula1:="8" Or Operator:=xlEqual, Formula1:="12" Range("B5,B7,B12,B14,B19,B21,B26,B28").Select Range("B28").Activate With Selection.Validation .Add Type:=xlValidateTextLength, AlertStyle:=xlValidAlertStop, _ Operator:=xlEqual, Formula1:="8" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with text length of cells
I'm not sure what you are lookinf for Mike. Maybe
Operator:=xlBetween, Formula1:="8", Formula2:="12" Maybe if you clarified what you are trying to achieve, we could figure something out. "Mike" wrote: Can someone help me modify this code to Allow Operator:=xlEqual, Formula1:="8" Or Operator:=xlEqual, Formula1:="12" Range("B5,B7,B12,B14,B19,B21,B26,B28").Select Range("B28").Activate With Selection.Validation .Add Type:=xlValidateTextLength, AlertStyle:=xlValidAlertStop, _ Operator:=xlEqual, Formula1:="8" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with text length of cells
JLGWhiz, Here it goes I have an Item Sheet that our Managers use to fill out and e-mail into our Corp Office Admin. The item sheet is for New Items meaning the items UPC Number needs to be added to our database. I would like a msgbox to display If the cells value is Not = to 8 Or 12 12345678 - No msg 1111111 - msgbox upc number must be 8 0r 12 digits long 123456781234 - No msg Does this help "JLGWhiz" wrote: I'm not sure what you are lookinf for Mike. Maybe Operator:=xlBetween, Formula1:="8", Formula2:="12" Maybe if you clarified what you are trying to achieve, we could figure something out. "Mike" wrote: Can someone help me modify this code to Allow Operator:=xlEqual, Formula1:="8" Or Operator:=xlEqual, Formula1:="12" Range("B5,B7,B12,B14,B19,B21,B26,B28").Select Range("B28").Activate With Selection.Validation .Add Type:=xlValidateTextLength, AlertStyle:=xlValidAlertStop, _ Operator:=xlEqual, Formula1:="8" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with text length of cells
I have just come up with this. Maybe you could offer some alternative or
away to make shorter Private Sub Worksheet_SelectionChange(ByVal Target As Range) Const purItem1 = "B5" Const subItem1 = "B7" Const purItem2 = "B12" Const subItem2 = "B14" Const purItem3 = "B19" Const subItem3 = "B21" If Len(Range(purItem1).Text) = 0 _ Or Len(Range(purItem1).Text) = 8 _ Or Len(Range(purItem1).Text) = 12 Then 'Do nothing if = to Else MsgBox "false" Range(purItem1).Value = "" End If If Len(Range(subItem1).Text) = 0 _ Or Len(Range(subItem1).Text) = 8 _ Or Len(Range(subItem1).Text) = 12 Then Else MsgBox "false" Range(subItem1).Value = "" End If If Len(Range(purItem2).Text) = 0 _ Or Len(Range(purItem2).Text) = 8 _ Or Len(Range(purItem2).Text) = 12 Then Else MsgBox "false" Range(purItem2).Value = "" End If If Len(Range(subItem2).Text) = 0 _ Or Len(Range(subItem2).Text) = 8 _ Or Len(Range(subItem2).Text) = 12 Then Else MsgBox "false" Range(subItem2).Value = "" End If If Len(Range(purItem3).Text) = 0 _ Or Len(Range(purItem3).Text) = 8 _ Or Len(Range(purItem3).Text) = 12 Then Else MsgBox "false" Range(purItem3).Value = "" End If If Len(Range(subItem3).Text) = 0 _ Or Len(Range(subItem3).Text) = 8 _ Or Len(Range(subItem3).Text) = 12 Then Else MsgBox "false" Range(subItem3).Value = "" End If End Sub "JLGWhiz" wrote: I'm not sure what you are lookinf for Mike. Maybe Operator:=xlBetween, Formula1:="8", Formula2:="12" Maybe if you clarified what you are trying to achieve, we could figure something out. "Mike" wrote: Can someone help me modify this code to Allow Operator:=xlEqual, Formula1:="8" Or Operator:=xlEqual, Formula1:="12" Range("B5,B7,B12,B14,B19,B21,B26,B28").Select Range("B28").Activate With Selection.Validation .Add Type:=xlValidateTextLength, AlertStyle:=xlValidAlertStop, _ Operator:=xlEqual, Formula1:="8" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with text length of cells
The Len() function would seem to be best for what you want to do. You could
probably shorten your code if you used an array for your list of cells, then you could do something like: myArray = Array("B5", "B7", "B12"...etc.) For i = LBound(myArray) To UBound(myArray) If Len(Range(myArray(i))) < "8" Or Len(Range(myArray(i))) < "12" Then 'Take some action End If Next "Mike" wrote: I have just come up with this. Maybe you could offer some alternative or away to make shorter Private Sub Worksheet_SelectionChange(ByVal Target As Range) Const purItem1 = "B5" Const subItem1 = "B7" Const purItem2 = "B12" Const subItem2 = "B14" Const purItem3 = "B19" Const subItem3 = "B21" If Len(Range(purItem1).Text) = 0 _ Or Len(Range(purItem1).Text) = 8 _ Or Len(Range(purItem1).Text) = 12 Then 'Do nothing if = to Else MsgBox "false" Range(purItem1).Value = "" End If If Len(Range(subItem1).Text) = 0 _ Or Len(Range(subItem1).Text) = 8 _ Or Len(Range(subItem1).Text) = 12 Then Else MsgBox "false" Range(subItem1).Value = "" End If If Len(Range(purItem2).Text) = 0 _ Or Len(Range(purItem2).Text) = 8 _ Or Len(Range(purItem2).Text) = 12 Then Else MsgBox "false" Range(purItem2).Value = "" End If If Len(Range(subItem2).Text) = 0 _ Or Len(Range(subItem2).Text) = 8 _ Or Len(Range(subItem2).Text) = 12 Then Else MsgBox "false" Range(subItem2).Value = "" End If If Len(Range(purItem3).Text) = 0 _ Or Len(Range(purItem3).Text) = 8 _ Or Len(Range(purItem3).Text) = 12 Then Else MsgBox "false" Range(purItem3).Value = "" End If If Len(Range(subItem3).Text) = 0 _ Or Len(Range(subItem3).Text) = 8 _ Or Len(Range(subItem3).Text) = 12 Then Else MsgBox "false" Range(subItem3).Value = "" End If End Sub "JLGWhiz" wrote: I'm not sure what you are lookinf for Mike. Maybe Operator:=xlBetween, Formula1:="8", Formula2:="12" Maybe if you clarified what you are trying to achieve, we could figure something out. "Mike" wrote: Can someone help me modify this code to Allow Operator:=xlEqual, Formula1:="8" Or Operator:=xlEqual, Formula1:="12" Range("B5,B7,B12,B14,B19,B21,B26,B28").Select Range("B28").Activate With Selection.Validation .Add Type:=xlValidateTextLength, AlertStyle:=xlValidAlertStop, _ Operator:=xlEqual, Formula1:="8" .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Total Text Length of Adjacent Cells | Excel Discussion (Misc queries) | |||
Extract text on right of various length from cells | Excel Discussion (Misc queries) | |||
length of text string goes beyond cells are not visible | Excel Discussion (Misc queries) | |||
want to remove all text characters equal to one character in length from text string | Excel Worksheet Functions | |||
Macro or Function to make text size to suite text Length? | Excel Discussion (Misc queries) |