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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
In VBA you can use the LTrim function to trim spaces from the beginning.
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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