PDA

View Full Version : [SOLVED:] Adding a common value to a column.



Chris123
12-16-2014, 10:20 AM
*first time attempting to use VBA
*mac excel 2011

Looking to add a common value within the range D1 to D8000 on Sheet1.
Example:
Current sheet contains the following;
D1 = 123
D2 = 583
D3 = 229
etc...to D8000

I need to add the letters "ALB" prior to each of these numbers. (They could be added at the end just the same, if there is a difference.)

What I need:
D1 = ALB123
D2 = ALB583
D3 = ALB229
etc...

(The "ALB" could be added at the end just the same, if there is a difference.)

SamT
12-16-2014, 11:47 AM
I don't have a Mac, but in Windows, the Helper Column Formula would be
(Copy formula down to D8000)

=Concatenate("ALB",D1)

The VBA Code would be

Sub ALB()
Dim Cel As Range
For Each Cel in Range("D1:D8000")
If Cel.Value <> "" Then
Cel.Value = "ALB" & Cel.Value
End If
Next Cel
End Sub
Place Code on the Code Page of the worksheet to be worked on.

Chris123
12-16-2014, 11:59 AM
Thank you, worked perfect!