How To Add A Letter To Every Cell In A Column That Contains A Letter Or Num?

vcaruso

New Member
Joined
Aug 19, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have a list of Lat/Lon coordinates on an Excel sheet that I want to import into my GPS/Plotter on my boat. However, I want to differentiate the newly imported coordinates that I am importing by prefacing them with the letter "L" or a special character. So the coordinate names are in one column of the sheet called "name" for the coordinate names. Within those cells are the names of 1200 coordinate names but I don't want them to mix in with my existing coordinates hence the need to differentiate them with a letter or special character. Any help solving this is greatly appreciated as I am a wreck when it comes to Excel. I can take you out into the Gulf Of Mexico and promise you will come home with dinner though. :)

Thank you,
Vince

coordinates.JPG
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Welcome to the MrExcel board!

Generally better to give your sample data (& expected results) in a way that helpers can easily copy to test with. I suggest that you investigate XL2BB

I am not entirely sure I have understood what you want so definitely test this with a copy of your workbook.

VBA Code:
Sub Add_Prefix()
  Const myPrefix As String = "L"  '<- Change if you want
  
  With Range("C2", Range("C" & Rows.Count).End(xlUp))
    .Value = Evaluate("""" & myPrefix & """&" & .Address)
  End With
End Sub
 
Upvote 0
An alternative solution is with Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"x", type text}, {"Y", type text}, {"name", type text}, {"cmt", type text}}),
    #"Added Prefix" = Table.TransformColumns(#"Changed Type", {{"name", each "L" & _, type text}})
in
    #"Added Prefix"
 
Upvote 0
Thank you both. I will try the suggested solutions. Sorry for the delayed reply, I had some health problems that kept me away from access to a computer.
 
Upvote 0
Unfortunately, both methods are above my skill level in Excel and I have no programming skills at all. :(

I attempted both solutions, but no success. I may have chosen a forum that is above my experience level as none of the suggested code appeared intuitive to me. :( I am truly a novice with Excel. It is very kind of you both to help out and I appreciate that very much. I hope the uploaded data helps, I impressed myself that I got the mini-sheet macro to work.

I am wanting to modify the "Name" column to preface it with a special letter or character. In my original post, I used the letter "L" as an example.

Thank you and best regards,
Vince

sample GPS numbers.xlsx
ABCD
1XYNameComment
2-83.127927.9467352 WRECKOLD WRECK REMAINS WI
3-82.819927.443887MILE14110 FT BARGE WITH ST
4-82.9328.50833BRIDGESKYWAY BRIDGE PARTS
5-83.126729.00528CHORSESEAHORSE REEF AREA
6-82.892828.01432CLEARWATERVARIOUS REEF MATERIA
Sheet1
 
Upvote 0
methods are above my skill level in Excel
To implement my suggestion

1. With your workbook active press Alt+F11 to bring up the vba window.
2. In the Visual Basic window use the menu to Insert|Module
3. Copy and Paste the code from post #2 into the main right hand pane that opens at step 2.
4. Close the Visual Basic window.
5. Press Alt+F8 to bring up the Macro dialog
6. Select the Add_Prefix macro & click ‘Run’
7. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm)

If you still have trouble or want a more manual approach you can do something like this.
Use a vacant column to the right to enter the formula shown and copy that down to the bottom of your data.
Then select the data in that new column (F2:F10 for me) and Copy
Select C2 - Right click - Select Paste Special.. - Values - OK
Then delete the formulas from column F

vcaruso.xlsm
CDEF
1name
245 WRECKL45 WRECK
352 WRECKL52 WRECK
4Other 1LOther 1
5Other 2LOther 2
6Other 3LOther 3
7Other 4LOther 4
8Other 5LOther 5
9Other 6LOther 6
10Other 7LOther 7
11
Sheet1
Cell Formulas
RangeFormula
F2:F10F2="L"&C2
 
Upvote 0
Well how about that. Your magic or should I say logic worked very well. Very thankful for your continued help & patience with me. Glad to know this resource exists. Hopefully I can return a favor some day. If you every need advice on offshore fishing in Florida, hit me up.

Thank you,
Vince Caruso
Palm Harbor, FL
 
Last edited by a moderator:
Upvote 0
You're welcome. Thanks for the follow-up. :)

BTW, I removed your link and picture. The link might be construed as trying to advertise through the forum and in any case it did not work for me. But thanks for the offer - though you are a long way from Australia! 😎
 
Upvote 0
To use Power Query here is some information

Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

- Follow this link to learn how to install Power Query in Excel 2010 / 2013.

- Follow this link for an introduction to Power Query functionality.

- Follow this link for a video which demonstrates how to use Power Query code provided.
 
Upvote 0
You're welcome. Thanks for the follow-up. :)

BTW, I removed your link and picture. The link might be construed as trying to advertise through the forum and in any case it did not work for me. But thanks for the offer - though you are a long way from Australia! 😎
Definitely not advertising, just trying to show you what it is I do. Thanks for taking care of the post.
 
Upvote 0

Forum statistics

Threads
1,215,335
Messages
6,124,327
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top