Trim function on the same cell in multiple sheets

brasqo

New Member
Joined
Jul 10, 2019
Messages
1
Hi everyone,

Hoping someone could point me in the right direction.

I have a worksheet with multiple sheets that are all identical in layout (an export from another program)

I need to trim one cell (F12) in each of these sheets.
I've used the following formula on a cell to have it trim correctly and apply the trimmed output to a different cell (trimmed Cell A1, and put the result in B1 for example).. :
Code:
TRIM(RIGHT(A1,FIND(" ", A1)+1))
But in this case, I need the trimming and application to to occur on the same cell.

IE: I need "Hello HDC05- Hxxxx / HDC00" in cell F12 to become "HDC00" in the same F12 cell.
Each sheet has a different value in F12, but in the same format as the example above.

Any direction in figuring this out would be appreciated.

Thank you!
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Aryatect

Active Member
Joined
Jun 17, 2019
Messages
308
Hi,

You can select all the tabs and where you need to apply the formula and enter the formula in any one tab in cell F12 and it will be copied in all tabs.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
42,721
Office Version
365
Platform
Windows
How about
Code:
Sub brasqo()
   Dim Ws As Worksheet
   
   For Each Ws In Worksheets
      With Ws.Range("F12")
         .Value = Split(.Value)(UBound(Split(.Value)))
      End With
   Next Ws
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,102,439
Messages
5,486,897
Members
407,570
Latest member
cannotquitexcel

This Week's Hot Topics

Top