View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Add a character to all cells in a column

Dim res as Variant, rng as Range
res = Application.Match("Color",Range("A1:IV1"),0)
if not iserror(res) then
set rng = Range(.Cells(2,res),.Cells(rows.count,res))
for each cell in rng.SpecialCells(xlConstants)
cell.Value = "j" & cell.Value
Next
End if

--
regards,
Tom Ogilvy


"glenn" wrote:

Hi all

how would i go in VBA to do this:

I have a single worksheet and i have a column with heading COLOR. I do
not know what position color has in my worksheet (it could be column B,
C or any other).

I want to prepend a character "j" to all cells in the column that have a
value.

So if my column initially is like:

COLOR
==========
yellow
pink
orange


after i run the VBA script

it should be

COLOR
==========
jyellow
jpink
jorange





thank you!