Add common prefix to all cells in Excel

前端 未结 10 1516
夕颜
夕颜 2020-12-23 11:12

I have a column with some text in each cell.
I want to add some text, for example \"X\", at the start of all cells. For example:

A             B
-----  &         


        
相关标签:
10条回答
  • 2020-12-23 11:30

    Select the cell you want,

    Go To Format Cells (or CTRL+1),

    Select the "custom" Tab, enter your required format like : "X"#

    use a space if needed.

    for example, I needed to insert the word "Hours" beside my numbers and used this format : # "hours"

    0 讨论(0)
  • 2020-12-23 11:36

    Michael.. if its just for formatting then you can format the cell to append any value.

    Just right click and select Format Cell on the context menu, select custom and then specify type as you wish... for above example it would be X0. Here 'X' is the prefix and 0 is the numeric after.

    Hope this helps..

    Cheers...

    0 讨论(0)
  • 2020-12-23 11:42

    Type this in cell B1, and copy down...

    ="X"&A1
    

    This would also work:

    =CONCATENATE("X",A1)
    

    And here's one of many ways to do this in VBA (Disclaimer: I don't code in VBA very often!):

    Sub AddX()
        Dim i As Long
    
        With ActiveSheet
        For i = 1 To .Range("A65536").End(xlUp).Row Step 1
            .Cells(i, 2).Value = "X" & Trim(Str(.Cells(i, 1).Value))
        Next i
        End With
    End Sub
    
    0 讨论(0)
  • 2020-12-23 11:42

    Another way to do this:

    1. Put your prefix in one column say column A in excel
    2. Put the values to which you want to add prefix in another column say column B in excel
    3. In Column C, use this formula;

    "C1=A1&B1"

    1. Copy all the values in column C and paste it again in the same selection but as values only.
    0 讨论(0)
  • 2020-12-23 11:44

    Go to Format Cells - Custom. Type the required format into the list first. To prefix "0" before the text characters in an Excel column, use the Format 0####. Remember, use the character "#" equal to the maximum number of digits in a cell of that column. For e.g., if there are 4 cells in a column with the entries - 123, 333, 5665, 7 - use the formula 0####. Reason - A single # refers to reference of just one digit.

    0 讨论(0)
  • 2020-12-23 11:47

    Select the cell you want to be like this, Go To Cell Properties (or CTRL 1) under Number tab in custom enter "X"#

    0 讨论(0)
提交回复
热议问题