YasserKhalil
Well-Known Member
Hello everyone
I am trying to sort by legnth the values in column A using the code
It doesn't give any error but it doesn't do the task
Althouth if I gave up the With .. End With it works
What is the reason for that ..?
I am trying to sort by legnth the values in column A using the code
Code:
Sub SortByLEN()
With Range("B1:B10")
.FormulaR1C1 = "=LEN(RC[-1])"
.Sort Key1:=Range("B1:B10"), Order1:=xlDescending, Header:=xlNo
.ClearContents
End With
End Sub
Althouth if I gave up the With .. End With it works
Code:
Sub SortByLEN()
Range("B1:B10").FormulaR1C1 = "=LEN(RC[-1])"
Range("A1:B10").Sort Key1:=Range("B1:B10"), Order1:=xlDescending, Header:=xlNo
Range("B1:B10").ClearContents
End Sub