7

How to convert text to uppercase (or lowercase) in-place in Excel / Office 365?

This page suggests to use the Change Case button, but there's no such button in my copy of Excel, and it does not even appear in the list of available buttons when customizing the Ribbon.

EDIT: The Change Case button appears to be in Word, not Excel. However, the question stays: is there a similar button/option in Excel?

3
  • 2
    I don't believe Excel ever had a 'Change case' (I even verified in custom ribbon, all commands). Your screenshot implies the workaround: copy into Word, change case, then I guess it has step four missing: copy back into Excel
    – gregg
    Commented Aug 16, 2023 at 13:05
  • Ah, I see. You're right. I am editing the post. Thanks for the correction.
    – dr_
    Commented Aug 16, 2023 at 13:14
  • Perhaps you could explore using an add-in, either creating your own or an existing one.
    – gns100
    Commented Aug 16, 2023 at 15:14

7 Answers 7

12

One way to do this is through VBA. You don't even have to write a macro, just select all the cells you want to convert, hit Alt-F11 followed by Control-G, and type:

For Each myCell In Selection.Cells : myCell.Value = UCase(myCell.Value) : Next

This will convert all the selected cells to uppercase (note that if the cell has a formula, it will change it to its current value!)

2
  • Excel functions exist to do this, you don't need VBA. But kudos for suggesting an alternative solution that's not a workaround. Commented Aug 16, 2023 at 12:55
  • 10
    @spikey_richie, I know, but the question was "in place", so you'd have to enter the formula somewhere else and then copy/paste values on top of the original. I thought this was easier :-)
    – Paul
    Commented Aug 16, 2023 at 13:11
6

This doesn't scale very well to large numbers of cells, but an in-place version of @spikey_richie's answer is:

  • Start with your existing text:

    existing text

  • Edit the expression in the formula bar to surround the existing text with =upper(" and "), but don't press enter:

    enter the expression

  • Now press F9 to evaluate the expression, which will replace the formula in the cell with the calculated value:

    evaluate the expression

  • And then press enter to accept the value:

    accept the value

Note if there are special characters like double-quotes in the string you'll need to escape those as well, so this approach has limited usefulness, but it can be handy for a quick bodge.

The F9 key is also useful for other expressions - I frequently use =TODAY() + F9 to enter today's literal date into a cell so I don't have to look at my calendar :-).

6
  • 4
    "I frequently use =TODAY() + F9 to enter today's literal date into a cell so I don't have to look at my calendar :-)." Just use Ctrl + .
    – Arsenal
    Commented Aug 17, 2023 at 11:25
  • @Arsenal - I'm always looking for extra keyboard shortcuts, but I'm not quite sure I get what you mean. I just tried "ctrl +" and it seems to do the same as F9, but maybe I'm misunderstanding?
    – mclayton
    Commented Aug 17, 2023 at 13:31
  • Go to an empty cell and use Ctrl + . (that is the period key not the period to end the sentence) it will insert the current date.
    – Arsenal
    Commented Aug 17, 2023 at 14:30
  • 2
    Ah, got you. It's an unfortunate coincidence that [ctrl] + [+] also evaluates an expression :-). Having said that [ctrl] + [ . ] (dot) didn't work here for the date - the documentation at support.microsoft.com/en-gb/office/… says it's [ctrl] + [ ; ] (semicolon) which does work for me...
    – mclayton
    Commented Aug 17, 2023 at 14:34
  • 3
    Oh then maybe they use different shortcuts for the German Excel, or our company uses a different mapping, but I've known [ctrl] + [.] to work for more than 6 years and I changed companies in between, so I think it's more of a German / English thing...
    – Arsenal
    Commented Aug 17, 2023 at 14:56
3

The page you have linked to gives several different methods for converting case in Excel. The button in the screenshot you have pasted is actually in MS Word, not MS Excel. The guide is suggesting you copy the text from Excel to a table in Word, change case using the button on the Word ribbon bar, then copy-n-paste it back into Excel.

2
  • 1
    This is a workaround, not a solution. Commented Aug 16, 2023 at 12:55
  • 2
    You are correct. @gregg pointed that out, too. I have edited the post.
    – dr_
    Commented Aug 16, 2023 at 13:17
3

Use Excel's =Upper() and =Lower() functions.

Uppercase

enter image description here

Lowercase

enter image description here

There's also =Proper(), which outputs like this:

enter image description here

You can then copy values of the correctly formatted cell, over the top of the original incorrect text.

4
  • 2
    This doesn't change the text in existing cells in place.
    – pts
    Commented Aug 16, 2023 at 20:51
  • @pts was that an explicit requirement in the OP's question? Commented Aug 16, 2023 at 20:52
  • 3
    Both the question title and text contain in-place, and this is how I interpret it.
    – pts
    Commented Aug 16, 2023 at 20:55
  • @pts you're right, I missed that bit. I've updated my answer to include additional detail which would meet this criterion. Commented Aug 16, 2023 at 20:56
2

You can use the Automate tab to create and run Office scripts if you meet the requirements. These scripts are like macros but they are written in TypeScript and are saved to your Office account so you can reuse them in other workbooks.

Here is an example of a script that changes the case of selected cells in-place on a cell-by-cell basis.

function main(workbook: ExcelScript.Workbook) {
    
    const selectedRange = selectedSheet.getSelectedRange();
    const rowCount = selectedRange.getRowCount();
    const colCount = selectedRange.getColumnCount();

    for (let c = 0; c < colCount; c++) {
        for (let r = 0; r < rowCount; r++) {

            const cell = selectedRange.getCell(r, c);
            const text = cell.getText();
            
            if (text.length === 0) {
                continue;
            }

            const isLower = text[0] === text[0].toLowerCase();

            if (isLower) {
                cell.setValue(text.toUpperCase());
            } else {
                cell.setValue(text.toLowerCase());
            }
        }
    }
}
1

Yet another way of using VBA functions.

You can also invoke VBA functions from the Name Box. Don't need equal sign, may use arguments, references may be also in R1C1 style (local), punctuation also local. Function must return reference. For example:

Function UP(rng As Range) As Range
      Dim c As Range
      For Each c In rng
            c.FormulaLocal = UCase(c.FormulaLocal)
      Next c
      Set UP = ActiveCell
End Function

In the Name Box: UP(D3:H5), UP((A3;B5;C2)) (use local separators, press Enter)

Function UPS() As Range
   Dim c As Range
   For Each c In Selection
      c.FormulaLocal = UCase(c.FormulaLocal)
   Next c
   Set UPS = Selection
End Function

In the Name Box: UPS() (use empty brackets, press Enter) A range for conversion should be previously selected.

0

In-place in Excel? Not really, there is practically non-existent support for regex.

Luckily, copying data from Excel puts it in tab-separated format so you could use a competent text editor to achieve the results:

  1. Copy your data from Excel enter image description here
  2. Paste into Notepad++ or anything with robust regex support like regex101.com enter image description here
  3. Initiate regex find+replace
    • Find: [a-z] or you can use . instead to account for non-English characters
    • Replace: \U$0
    • Alternatively, you could select all the text and use Ctrl+Shift+U
  4. Replace All enter image description here
  5. Copy+Paste back into Excel enter image description here
2
  • 1
    Or if formatting & formulae aren't an issue, then Save-As-CSV then change case in a text editor, re-open the file in Excel - cuts out the potentially messy cut-n-paste.
    – MikeB
    Commented Aug 18, 2023 at 9:49
  • In-place in Excel? Not really, there is practically non-existent support for regex. 1) In-place replacement has nothing to do with regex. 2) It's not true that Excel doesn't support regex insider.microsoft365.com/en-us/blog/… 3) You can do in-place text replacement easily with special paste, or with either VBA or F9 as many answers before you 4) Even if you use regex then any regex support won't work because each regex engine has different features, some may have uppercase replacement, some may not'
    – phuclv
    Commented Jun 30 at 7:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .