Trying to insert a "," in the 7th position from the right, if a cell length is > 6 AND the Cell contains a " . "
Printable View
Trying to insert a "," in the 7th position from the right, if a cell length is > 6 AND the Cell contains a " . "
Off the top
Code:If Len(cell).Value) > 6 And Instr(cell,".") > 0 Then
cell.Value = Left$(cell.Value, 6) & "," & Mid$(cell.Value, 7,255)
End If
Thanks Bob Phillips :
But This is putting the "," 7 places from the Left, not the 7th position from the Right.
Is this what you mean Bob meant?
Code:= Left$(c.Value, Len(c) - 6) & "," & Mid$(c, Len(c) - 5, 6)
Thanks jolivanes;
This solution is what worked.
Thanks for the efforts of all who contributed.Code:If Len(cell.Value) > 6 And InStr(cell, ".") > 0 Then
cell.Value = Left$(cell.Value, Len(cell) - 6) & "," & Mid$(cell, Len(cell) - 5, 6)
End If
Sufficient:
Avoid variable names that can interfere with VBA names.Code:If (Len(cl) > 6)*InStr(cl, ".") Then cl = Left(cl, Len(cl) - 6) & "," & Mid(cl, Len(cl) - 5)
Code:Len(cl)
correct.
as usual!
snoever :whistle:
As ge oe čige nie kietelt dan laŕchte nooit!:hi:
Kruikezeikers ?
Parel vh zuiden aka 't kielegat
compris !