PDA

View Full Version : [SOLVED:] Text code



Tony Singh
12-06-2013, 08:43 AM
Hi
A programme I use requires a minimum of 8 characters to a code, anything less
and the programme will not pick up the entry unless I complete the code by adding
an X to the end to make the total characters up to a maximum of 8.
I have only managed to come up with the following:


Sub Macro1()
Dim C As Range
For Each C In Selection
If C.Value <> "" Then C.Value = C.Value & "XXX"
Next
End Sub

I would appreciate some help.

Thanks

sassora
12-06-2013, 09:33 AM
Does this kind of thinking work?


Sub Macro1()
Dim C As Range
For Each C In Selection
If C.Value <> "" and len(C.Value) < 8 Then C.Value = C.Value & String(8 - len(C.Value),"X")
Next
End Sub

Tony Singh
12-06-2013, 10:18 AM
Perfect, worked exactly as wanted.
Thanks for your help Sassora