Prefix

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi, does anyone know if it is possible to take a column of data and
auto prefix each word in the cell with zz

So for example:

Alan
Brian
Craig
George

would become

zzAlan
zzBrian
zzCraig
zzGeorge


Thanks in advance

Steve
 
Hi Steve,

Am Wed, 31 Oct 2012 20:37:19 +0000 schrieb Steve:
So for example:

Alan
Brian
Craig
George

would become

zzAlan
zzBrian
zzCraig
zzGeorge

your names in column A. Then with formula
="zz"&A1 and copy down, copy and paste special => paste values

or do it with VBA: Select your names and run this macro:

Sub ZZ()
Dim rngC As Range

For Each rngC In Selection
rngC = "zz" & rngC
Next
End Sub


Regards
Claus Busch
 
Hi Steve,

Am Thu, 01 Nov 2012 22:14:00 +0000 schrieb Steve:
Alan
George
Adam
Colin
Aaron
Alex

So if i filtered for the name beginning with A to prefix them with zz

zzAlan
George
zzAdam
Colin
zzAaron
zzAlex

following code works for column A and first character "A" - modify to
suit:

Sub ZZ()
Dim LRow As Long
Dim rngC As Range

LRow = Cells(Rows.Count, 1).End(xlUp).Row
For Each rngC In Range("A1:A" & LRow)
If InStr(1, rngC, "A") = 1 Then
rngC = "zz" & rngC
End If
Next
End Sub


Regards
Claus Busch
 
Thanks very much Claus that works perfectly.

Do you know if it would also work if the cells were not consecutive

Alan
George
Adam
Colin
Aaron
Alex

So if i filtered for the name beginning with A to prefix them with zz

zzAlan
George
zzAdam
Colin
zzAaron
zzAlex


Thanks again

Steve
 
Back
Top