View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
[email protected] lhkittle@comcast.net is offline
external usenet poster
 
Posts: 168
Default how to add a letter to front of column sample ID

On Friday, November 9, 2012 1:09:10 PM UTC-8, msdelila wrote:
I have an excel spreadsheet consisting of columns of "patient ID's" and

then various columns of "numerical values".



Some patient ID's are "DD-0002-0001PK" as an example. I Want to add a

"L" to some of those sample names....like "DD-0002-001PK-L" how can I

do that?



I can't just put ="L"&A1, because my values are text and if I do that it

just changes it to a 0, and I need those ID labels, but I don't want to

have to go back manually and type in "L". Is there anyway that I can

put "L" on the back of the first 40 ID's?









--

msdelila


Hi msdelila,

joeu2004 has given you plenty to chew on and solve your query.

Here is a little snippet of vba code that may be of use if you want to go that way.

I did a drop-down list in F1, perhaps you have a few different letters you may want to choose for various patients.

Click in F1 and select the desired letter to add to the ID's. (Or just enter the letter in F1.)

In the Patient ID's list select all the patients you want to add F1 to (use the ctrl key to select as many as you want).

Run the code. I assigned a short-cut key, ctrl + p, to the macro which you could do also.

Option Explicit

Sub AddToIt()
Dim c As Range
For Each c In Selection
c.Value = c.Value & "-" & Range("F1").Value
Next
End Sub

HTH
Regards,
Howard