Remove lines with blanks in front

rowdy2k5

New Member
Joined
Nov 14, 2011
Messages
31
Hi!

I have a text file with entries of the following form:

Code:
TextLine1

    TextLine2


In the second case, there are 4 blank spaces before there is any text in the line. How do I import only those lines which have no blank spaces in front?
Or: if I import the file as it is, how do I remove all the rows with 4 blanks in front?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Import all, then in cells to the right
=if(left(a1,1)=" ","",a1)

'if the lefthand 1st char in cell a1 is a space, give me nothing, otherwise give me a1
 
Upvote 0
Try
Code:
=TRIM(A1)

and copy down as far as needed
 
Upvote 0
Trim does not help me much, because then I have a list with all entries in A1, with no spaces in front. But I want to delete those entries with spaces in front. I don't want to delete the spaces in front.
 
Upvote 0
Import all, then in cells to the right
=if(left(a1,1)=" ","",a1)

'if the lefthand 1st char in cell a1 is a space, give me nothing, otherwise give me a1

Ok, that works. Let's say I have now entries, where some entries have 2 spaces in front and others have 4 spaces in front. How do I need to change the formula to keep those with 2 spaces in front?
 
Upvote 0
=if((left(a1,2)=" ")*(NOT(left(A1,4)=" ")),"",a1)
 
Upvote 0

Forum statistics

Threads
1,203,101
Messages
6,053,532
Members
444,670
Latest member
laurenmjones1111

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