Help please: There is the following macro:
Private Sub Worksheet_Change(ByVal Target As Range) Dim objCell As Range With Target If .Column < 1 Or .Column > 5 Or .Row < 1 Or .Row > 100000000 Then Exit Sub End With For Each objCell In Target If TypeName(objCell.Value) = "String" Then objCell.Value = Left(objCell.Value, 10) End If Next End Sub It responds to a change in the cells of the range <1 or> 5. And if it is greater than 10, it cuts the value to 10. How can I add this check in several columns? That is, you need something like:
Private Sub Worksheet_Change(ByVal Target As Range) Dim objCell As Range With Target If .Column < 1 Or .Column > 5 Or .Row < 1 Or .Row > 100000000 Then Exit Sub End With For Each objCell In Target If TypeName(objCell.Value) = "String" Then objCell.Value = Left(objCell.Value, 10) End If With Target If .Column < 7 Or .Column > 9 Or .Row < 1 Or .Row > 100000000 Then Exit Sub End With For Each objCell In Target If TypeName(objCell.Value) = "String" Then objCell.Value = Left(objCell.Value, 4) End If Next End Sub But at the same time swears. Help me please.