Excel - add file extensions to a column

Asked By The DL on 14-Jan-08 06:14 PM
Hello, I would like to add the file extension .jpg to the end of the contents
of every cell in column A.

Right now I have cells with contents like

2004-11-034

and I would like to end up with

2004-11-034.jpg

I am new at all this, and can't for the life of me find a solution. Any help
would be much appreciated. thank you!




Tyro replied on 14-Jan-08 06:22 PM
Put =A1&".jpg" in cell B1 and drag down in column B for every cell you want
to change in column A.

Tyro
Gord Dibben replied on 14-Jan-08 07:27 PM
In B1 enter      =A1 & ".jpg"

Double-click on the fill handle(bottom right corner black lump) of B1 to copy
down.

Whe happy with results, select column B and, in place, Edit>Paste
Special>Values>OK>Esc.

Delete column A


Gord Dibben  MS Excel MVP


On Mon, 14 Jan 2008 15:14:00 -0800, The DLC <The DLC@>
T. Valko replied on 14-Jan-08 11:22 PM
Here's a macro that will do it in place:

Sub Addjpg()

Dim cell As Range
For Each cell In Selection
If cell.Value <> "" Then
cell.Value = cell.Value & ".jpg"
End If
Next cell
End Sub

Open the VBE editor: hit ALT F11
Open the project explorer: hit CTRL R
Find your file name in the pane that opens
Select your file name and right click
Select Insert Module
Copy/paste the code above into the window that opens on the right
Return back to Excel: hit ALT Q

Now, add the file extensions:

Select the range of cells where you want this to happen
Hit ALT F8
Select the Addjpg macro
Click the RUN button


--
Biff
Microsoft Excel MVP