Consulting

Results 1 to 3 of 3

Thread: Adding a common value to a column.

  1. #1
    VBAX Newbie
    Joined
    Dec 2014
    Posts
    3
    Location

    Adding a common value to a column.

    *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.)

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Newbie
    Joined
    Dec 2014
    Posts
    3
    Location
    Thank you, worked perfect!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •