How do i TRIM only from the beginning of a cell?

CaptainCsaba

Board Regular
Joined
Dec 8, 2017
Messages
78
Hey Everyone!

I created a macro a few months ago that help us to make some reports easier to input. There are multiple lines in these responses that we don't need and the only way to find the ones we do need I used the following method. All of the cells that we needed started with a number, had multiple spaces (between 6 and 10) and ended with text. So I created a code that offsets all the cells that begin with a number and have at least 4 spaces after that ("# "). And it worked perfectly but recently the reports got a bit different. All cells have at least 20 spaces at the beginning and it screws up the macro (later it does stuff that gets messed up because of this). So what was "apple" before is now " apple". I can't use the TRIM function because it removes the spaces between the numbers and the text and after that we won't have anything to offset.

So my question is: What code should I use in VBA (or formula) that removes all the spaces but only from the beginning of a cell?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
In VBA you can use the LTrim function to trim spaces from the beginning.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top