Adding suffix to column entries

N

NCdesigner

I have a column of 11,000 entries. These are stock numbers for a website
store. The image that goes with each item has the same number. I need to add
".jpg" to even entry in that column without doing it one-by-one. Can anyone
tell me how to do it?
 
M

Mike H

Hi,

This assumes column A so change to suit.
Right click your sheet tab, view code and paste this in.
WARNING this will add .jpg to everything in that column and even convert
formula to values with .jpg on the end. If there are other data in the column
then post back with details.

Sub appendJPG()
Dim MyRange As Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
If c.Value <> "" Then
c.Value = c.Value & ".jpg"
End If
Next
End Sub

Mike
 
N

NCdesigner

Thanks so much for your vuick response...I followed your instructions:
highlighted the column, right clicked the sheet tab, clicked the view tab,
and pasted in the code. The pull down menus at the top read (general) and
appendJPG. After doing this do I save "Book 1"?

I actually clicked File>Close and return to MicroSoft Excel but I didn't see
".jpg" added to the entries in the column. (I am using column A)
 
M

Mike H

Did you run the code?

Tools|Macro|Macros
select this workbook
Select the macro
Click Run

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top