Is there any shortcut for TRIM function in Excel?

Grzegorz Walesiak 1 Reputation point
2022-09-02T09:18:06.447+00:00

Is there any shortcut for TRIM function? For example I can press F2 and text in my cell is trimmed from both sides?

This solution will make life easier for a lot of people :)

Thank you in advance
Greg

Microsoft 365 and Office Excel For business Windows
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Emily Hua-MSFT 27,796 Reputation points
    2022-09-05T06:12:38.897+00:00

    Hi @Grzegorz Walesiak

    Sorry, we are unable to create the shortcut for one Excel function.

    But you can try to use VBA code, can create a shortcut for this macro.

    For example, I create a macro called Test, the shortcut is Ctrl+Shift+T.
    237689-capture7.png

    Sub Test()  
    Dim rng As Range  
    For Each rng In Selection  
    rng.Offset(0, 2) = Trim(rng)   'The result will be offset by 2 cells to the right, but on the same line'  
    Next rng  
    End Sub  
    

    Then I can choose the cells A1:A2 that need to be trimmed from both sides, press Ctrl+Shift+T, the results will be created on C1:C2.
    237722-capture8.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



  2. Nothing Left To Lose 396 Reputation points
    2022-09-05T22:06:41.827+00:00

    Re: "solution will make life easier for a lot of people"

    The drawback is you have to open the file and click a couple of buttons
    The benefit is that it Trims the entire sheet.

    237943-image.png

    The free "Professional_Compare" workbook has multiple utilities that work on Excel.
    Download from OneDrive...
    https://1drv.ms/u/s!Au8Lyt79SOuhZw2MCH7_7MuLj04?e=sAwbHU

    '---
    Nothing Left to Lose

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.