• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Prefixing existing codes

Hi, do you have a sample file with layout of what you need. It will help with a speedier reply if folks know exactly what you are trying to do. :)
 
E61700 2
E61L5 4UK
E65 2UK
E65100 2
E65200 2UK
E65200 2UK
E65300 2
E69 P
E72 ACUK
E72 P
E73 P
E76 P
E78001
E78002
E78003
E78004
E78900
E78901
E78AHB
E78BHB
E78CHB

I have a worksheet with codes as above, I need to Prefix them so they all have LY in front of the E

Hope this makes sense

Thanks
 
E61700 2
E61L5 4UK
E65 2UK
E65100 2
E65200 2UK
E65200 2UK
E65300 2
E69 P
E72 ACUK
E72 P
E73 P
E76 P
E78001
E78002
E78003
E78004
E78900
E78901
E78AHB
E78BHB
E78CHB

I have a worksheet with codes as above, I need to Prefix them so they all have LY in front of the E

Hope this makes sense

Thanks
Hi,

ALT+F11 to open VB editor, right click 'ThisWorkbook' and insert module and paste the code below in. Select all your data and run the code.

Code:
Sub Add_Prefix()
Dim c As Range
For Each c In Selection
  c.Value = "LY" & c.Value
Next
End Sub
 
Or a non looper:
Code:
Sub AddPref2()
With Selection
  .Value = Evaluate("IF(" & .Address & "<>""""" & "," & """LY""" & "&" & .Address & "," & """""" & ")")
End With
End Sub
 
Back
Top