Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Excel


Extract Left Most Characters Until A Space

I am trying to write a function that finds and breaks a cell about the first space.

Worksheet is:

=LEFT(name,FIND(" ",name)-1)

Have tried...

Function Firstname(name)

Dim Space As Integer

Set Space = .Find(" ", name)

Firstname = Left(name, Space)

End Function

and also...

Function Firstname(name)

firstname = left(name,find(" ",name)-1))

End Function

View Complete Thread with Replies

Sponsored Links:

Related Forum Messages:
Extract Left Characters Up Until Specified Text
I am attempting to utilize the Mid, Left, and Right functions to parse out data returned in a single cell. There are twelve months of data returned with the "title" listed after. I would like to be able to FIND the title and return a specific number of characters of data to the LEFT not the right (as Mid seems to do).


Cell A1{ 1 2 4 5 3 5 TITLE1 1 2 3 6 7 4 5 TITLE2 3 4 5 2 4 5 TITLE 4 }

Cell A2{ 1 2 4 5 3 5 TITLE2 1 2 3 6 7 4 5 TITLE3 3 4 5 2 4 5 TITLE 4 }

I would like to be able to search each cell for the "TitleX" then parse data out to the left of that title (and if not found, return "").

There are too many different Titles to use IF statements and I cannot change that the data comes to the left of the title.

View Replies!   View Related
Remove All Text Left Of Space And The Space
I have two words of differing character lengths separated by a space.

How can I remove the first word... essentially, all the charcters to the left of the space AND the space itself?

View Replies!   View Related
Pull Left And Right Until Space
I am blanking out. I want to pull the data out until a space (one formula from the left and one from the right). Ithink it's a mid function but not sure.


John, Doe

I would like to get:




View Replies!   View Related
Trim Left Of Space
Sub GetThatstring()
Dim strMonth As String
Dim iYear As Integer
Dim StrMnthYear As String

strMonth = Trim(Left( Range("A1"), _
InStr(1, Range("A1"), " ", vbTextCompare)))
MsgBox strMonth

iYear = Mid(Range("A1"), _
InStr(1, Range("A1"), " ", vbTextCompare) + 1, 4)
MsgBox iYear

StrMnthYear = Trim(Left(Range("A1"), _
InStr(1, Range("A1"), " ", vbTextCompare) + 4))
MsgBox StrMnthYear
End Sub

I have a column of cells likes:
5/5058 Jack Daniels
5/29AA Crown Royal

I want to delete everything to the left of the first space.
So it will look like:
Jack Daniels
Crown Royal

It has to be vba though. I have done alot of trim in just formulas but this is first time in VBA. The above code is one I found by searching but not sure what to do to modify it.
This will be for range AM2:AM2000

View Replies!   View Related
Pull From Left Until Blank (Space)
I'm looking for a formula that pulls the text from a cell unti it hits a space. I'm using the formula below but keep getting #VALUE results. B1: =LEFT(A1,FIND(",",A1,1)). I know it's not that hard but can't figure it out.

View Replies!   View Related
Separating Characters By Space
I have following kinds of texts in a column.


I want to convert above texts with space between every character as follows:

J B K U 3 4 8 5 9 7 - 3
T - 2 2 5
7 5 9 8 4

View Replies!   View Related
Finding Characters Before A 'space'
I am trying to find numbers before a space character.

For example...

In column return in column 2

23 cars................................................. 23
5 trucks................................................. 5
150 vans.............................................. 150

I can't use MID Function as it can be 4 numers long...

View Replies!   View Related
Adding Space To A String Of Characters
I need to add spaces to a string of characters so that it is readable, the database is huge so I cannot do it manually:

For example,
123456John Doe 3456Adam Sharp I need it to apperar as:
123456 John Doe 3456 Adam Sharp

but still remains at the same column. Is there a quick way to do this ?

View Replies!   View Related
Check Selection For Space After X Characters
I want to write a macro that will check every selected cell. It should detect if there is a space after the fourth character. If there is a space, go to the next selected cell. If there is no space, add a space and go to the next selected cell.

View Replies!   View Related
Formula To Find Characters After The Last Space In A String
I have text string and would like two formulas to find, 1) the characters after the last space and 2)to find the number of characters after the last space.

View Replies!   View Related
Remove Front Zeros & Add Space Before Last 2 Characters
I want to remove the front zero(s) from the front and put a space before the last two letters for the following column of data in Excel:


Final result will have this format and the data are right aligned.
1 MG
20 MG
100 MG
1000 MG

The numbers can vary (e.g. 0150MG, 0025MG,etc.) but the arrangement is always the same: four figures for the first 4 characters and two letters for the last two characters.
The format of the cells containing the data is: “General”

My table has 7 columns and these data are in the 5th column in a worksheet called “ProductSummary”. The number of rows for the records can vary from 10 to over a couple of hundred.

How can I use VBA to: 1) automatically select the table range in that worksheet and reformat all the data in the 5th column.

View Replies!   View Related
Determine If Cell Has White Space Only & No Characters
Using VBA, how can I determine if a cell contains only white spaces and NO valid characters?

View Replies!   View Related
Extract Text After Space In String
i have used the RIGHT function to remove the 1L/1S and the 1L from the samples belows

the problem i have is when the 1L is in its cell there are 3 spaces before it
how can i remove those spaces so that all the data is to the left of the cell

BYA001 1L/1S
BYA003 1L

View Replies!   View Related
Compare Left Most Characters
I have a series of alpha numerics items in Cells A1:A999 (i.e AB0001 to AB0999). I need to be able to perform a search the range (A1:A999), and extract items that do not conform to the standard AB prefix. Example, an item of BC0001 could be present in the range. I would need to have that item, either highlighted or displayed in a different column.

View Replies!   View Related
Get Left X Characters From A Cell
I am looking to write a formula in an excell cell to veiw some of the wording in another cell. I know how to say that i want to see the first or last "x" characters in a cell.. But how do i say that i want to see all the info/wording in a cell except the last "x" characters..

View Replies!   View Related
Show Characters Left Of Delimiter (,)
I need a formula, that will, Show the Characters Left of Delimiter (,).

for example:


View Replies!   View Related
Pull Left X Characters From AlphaNumerics
I want to take a lot of text fields with alphanumeric characters ie. " '49560-960-A908 "
(always beginning with the character " ' ") and display in another cell position 2 thur 6 ie. "49560"

I have a file that contains 3,500 cells with alphanumeric characters...always beginning with ' but I need the 1st 5 numbers after the ' in a second separate column

View Replies!   View Related
Add X Left Most Characters Of Range Into Cell
I'm trying to figure out why i'm getting this error: "Object variable or With block variable not set" for this

Sub Macro3()
Dim cel As Range
Dim str1 As String
Dim SearchThing As Range
Set SearchThing = ActiveSheet.Range("I34")
str1 = Left(SearchThing.Value, Len(SearchThing) - 4)
cel.Value = str1
End Sub

The error is specifically with this line

cel.Value = str1....................

View Replies!   View Related
Compare Cells By Suffix & Left Characters
I am using (in Column "B") the formula: =IF(A2=A3."",1), copied down as required, to uniquely identify entries in Column "A". In this instance "10", "10A", "10B" and "10C" located in "A5" through "A11" are viewed as the same. Is it possible to have the formula recognize the enties in "A5:A11" as a unique entry and therfore have "1" entered into cell "B11"? The suffix, if used will always be A thorugh Z.

View Replies!   View Related
Extract Numbers With Specific Text From Right Or Left
i use this code to get the value from the cell that contains "Ink"., and i got the codes from reading other problems:


like this in a1 -> Ink 253.00

and totally working! but the problem is if the word "ink" in the left of the value --> 253.00 ink and the result is #NA, is there any way that i can get the value whether the word Ink is in the left side or right side of the value?

also bothered why is it if the word is not "ink" in the cell and return -> #value since i put ("") in the last part of If function(value if false)?

View Replies!   View Related
Extract Numeric Characters
I have a column contains Postal Adress in more than 5000 rows. Column contains Door Number, Area, City and Zip code. I need to separate "Zip code" alone in next coulmn. Zip code (of India) will be in six digits like "600083" also some cases contain space in middle of zip code like "600 083" (after 3 digits). Is there any way to do this without doing cut & paste?

View Replies!   View Related
Extract Set Of Numeric Characters
I have a column contains Telephone numbers with or without area code and country code for across the country (India). I need to extract the telephone numbers alone (neither area code nor country code). Telephone numbers will be 6 or 7 or 8 digits (not more than that). Is it possible to extract any set of numbers contain 6 or 7 or 8 digits continously? Some of the cases contains 2 contact numbers (2 set of 6 or 7 or 8 digit characters, between special characters will be there like slash, comma, space, hypen, etc.,

Here are some examples: ....

View Replies!   View Related
Extract First & Last X Characters From Cells
Column A in Excel has loads of numbers all in this format 971-417. I need to have each of those two numbers in a separate cell from each other(and without the hyphen of course).

Column A Needs to be: Column A Column B
971-417 971 417

In short, I'm looking for a quick way to put each number in its own cell for hundreds of rows. Are there formulas I can use to do this or does it have to be done slowly, one at a time, stripping the information from one cell to another?

View Replies!   View Related
Extract Characters From Phrase
i have a list of information, and from that i want to extract a certain piece from that information and out it in a new cell...
eg. 'KLM00506', 'KLM00409-10', 'KLM00821-9' etc

as you can see, the info is not in the same length
what i need is to take out the FIRST 6 characters and have the remaining to be in a new cell

anyone has an excel formula that i can use ? not really interested in code, cause in this particular worksheet, everything is at its' place, no code required

View Replies!   View Related
Extract Text Separated By Characters
I need a Excel 2007 formula that will extract a string of text that is seperated by characters.


in Cell (A1) I have the following

ALA 11 : [ MOBILE ] 36619 1/2 ... HOME ... JUNE 2009 / TODAY: $ 50000

End Result wanted:

Cell (A2) 11
Cell (A3) MOBILE
Cell (A4) 36619 1/2
Cell (A5) HOME
Cell (A6) JUNE 2009
Cell (A7) 50000

View Replies!   View Related
Extract Text Characters Only From A Cell
This is very similar to my previous post, which was solved. Now that I've extract the numbers, I need to extract the text for the specific work activities, for example 13Z or 9GGG. I'm assuming some variation on this formula:


is the solution, but I'm struggling with making the correct alterations.

View Replies!   View Related
Extract Trailing String Of Characters From A URL
I have a problem that I just don’t seem to have the brain power to solve right now. I have a list of websites and I need to extract all characters after the last “/” in the URL. URL example:.....

I have been using the find function in conjunction with LEN and RIGHT etc but the multiple instances of “/” is causing headaches for me. Also, the trailing string of characters that I want to extract can be both text or numeric and are of differing lenths.

View Replies!   View Related
Alphanumeric Characters Extract Only The Numerics From Cell
I have the following in Column A


I'd like have this result


How would I achieve this.

View Replies!   View Related
Extract The First 5 Characters In A String, And Convert Them To A Number
Say I have a string "09800EBHR052708"

How would I take the first 5 characters and get a number out of them?

View Replies!   View Related
Extract X Number Of Characters Followed By Specific Character
How can I extract mid section of the string which is always 5 characters long and is always followed by a period "." ?

My account strings are in 3 sections (but the third section isn't always used)

For example,

View Replies!   View Related
Locate Text String After First Space And Before Last Space
I have been working on different formulas to return the text string between the first and last space and have been unsuccessful. Is this possible?

I have tried several combos or Left and Right, I have been able to get the values after the first space, and the values before the last space, but not between the spaces.

String: Y60

Desired results: D60

View Replies!   View Related
Character Extraction: Extract The Characters "9078.314" And Put Them In A Different Cell
Cell R2 contains this value: " Forecast Time: 240 Index A forecast = 9078.314". I want to extract the characters "9078.314" and put them in a different cell. The cell that it should be affected to depends on the characters "240". I believe I should use the MID() and VLOOKUP() functions but I get stuck at the very first step of extracting my data.

View Replies!   View Related
COUNTA Not To Counting Space Bar Space
I have the following formula that works fine until someone uses the space bar to clear a cells contents


When the space bar is used to clear a cells contents the COUNTA statements includes the space in the count. How do I count the number of cells with content and exclude the space bar space in a cell?

View Replies!   View Related
Autofill Formula To The Left (fill To The Left)
I am having trouble filling a formulae series to the left on one spreadsheet, the fomulae being references to another sheet.

For example, I have two sheets 'Mtce Options' and 'Base Case'. In 'Mtce Options' I have the following formulae

1='Base Case'!A15='Base Case'!D15='Base Case'!G15

I want to fill to the left, incrementing the column references by a factor of 2 each time, eg. next two should be ='Base Case'!J15 and ='Base Case'!M15.

However, if I autofill to the left by highlighting A1, B1 and C1 or just B1 and C1 all I get is an inappropriate reference such as ='Base Case'!D15 or ='Base Case'!F15, respectively, in D15.

View Replies!   View Related
Find/Left Functions: Grab Everything Left Of The Last Occurrence Of "." In A String
I want to grab everything left of the last occurrence of "." in a string, and in the next cell everything right of the last occurrence of "."

so say the string is
column 1

column 2

my current code (which works, but its messy) for the first cell is

View Replies!   View Related
Conditional Formatting Counting Characters If Less Than X Characters
I'm trying to use conditional formatting to highlight cells in a column that have less than 8 characters.

I know the LAN function, but I don't know how to make it work for the conditional formatting.

View Replies!   View Related
Put The Space
We have a system that used to export postcodes with the " "(space) in the correct space, the system has changed and no longer requires exposts with spaces

I need a formula that puts in the space depending on if it has 7 digits or 6

For Example

TE557TT needs to become TE55 7TT if postcode is 7 chracters " " after 4

TE57TT needs to become TE5 7TT if postcode is 7 chracters " "" " after 3

View Replies!   View Related
Blank Space Using 'IF'
At the top of my spreadsheet I've got the date displayed using TODAY(). In 'G5' theres a proposed collection date.
In 'F5' I entered, =IF(G5>$D$1+1,"PENDING","NOT COLLECTED"). Which is fine except, if 'G5' is blank I want 'F5' to be blank also. And if a date is removed from 'G5' I want 'F5' to be blank. I've tried various things with "" but I cant get it to do what I need. I'm sure this is very easily cured, but not by me clearly..!

View Replies!   View Related
Blank And Space
When using SUBTOTAL for counting values in a column, well this function is counting also the blanks cells having space inside

Well i can use an COUNTIF to avoid this problem, but when using autofilter , the count is gone, that's inconvenient.I can use autofilter to select blanks and then delete space inside but is quite long.

I chopped a macros inspired by jindon:

Sub SpacesBlanks()

Dim X As Integer
Dim r As Range
X = CLng(InputBox(Prompt:="Quelle colonne?"))
If (X < 1) + (X > Columns.Count) Then Exit Sub
lastRow = ActiveSheet.Cells(Rows.Count, X).End(xlUp).Row
For Each r In Range(Cells(1, X), Cells(Rows.Count, X).End(xlUp))
If r.Value = "" Then
r.Value = ClearContents
End If

End Sub

View Replies!   View Related
Add Space Before Capitals
I have a column with thousads of names

i.e. JohnSmith

Is there a custom way to delimited the text by Capitol letter.

Or, to have the text string searched and then insert a space in front of every caps it finds to get the output.

View Replies!   View Related
Putting A Space
how do I put a space?

12345 ** =A1&B2 gives me 12345CD

but I want 12345 **

View Replies!   View Related
Removing Space At The End Of A Value
I have a set of data in a column and I'm trying to add them but can't because of the way it was imported. Each cell has a number with a space at the end. How do I remove that space without having to manually go in there and deleting via F2 > backspace, F2 > backspace, and so on.

View Replies!   View Related
Add A Space Before Every Cell Value
I'm trying to automate the importing and processing of a fairly large formatted text file (~15000 lines) containing many tables of data. I've been refining this process for several months and recently was alerted to a problem. A few of my tables have widths greater than 255 characters (309 to be exact).

My process involves opening the text file in Excel then performing a .Copy on the Worksheet into ThisWorkbook, naming the sheet "Source". I then perform up to 66 separate parse operations on the various tables depending on which options a user selected from a form.

The problem is that I assumed that the Copy Method would simply make a duplicate of that sheet in ThisWorkbook. Instead, it seems to have truncated any columns that are longer than 255 characters, leaving me with partial data in a few tables.

My workaround was to perform a TextToColumns on the text file prior to the import such that it would simply split the data into columns that could be reassembled on the other side. In doing so, I seemed to have stripped a leading <space> from each cell which was apparently put there previously. This is causing a lot of problems for my formatting code which also uses TextToColumns to separate the tables into columns. The simplest solution seems to be trying to add the spaces back in, assuming there isn't a better way to import this data in the first place.

Just prior to copying the sheet into ThisWorkbook, I'm using the following code after the TextToColumns to add the space back in, but it's taking an awfully long time and causing a noticable time delay in processing my code and adding considerable size to the finished workbook it creates. If someone could recommend a better solution, either to the import process or to replace this God-awful loop, I'd appreciate it. Thanks.

Application. ScreenUpdating = False
For i = 1 To 65535
wkbk.Sheets(1).Cells(i,3).Formula = " " & wkbk.Sheets(1).Cells(i,1).Value
wkbk.Sheets(1).Cells(i,4).Formula = " " & wkbk.Sheets(1).Cells(i,2).Value
wkbk.Sheets(1).Cells(i,1).Formula = wkbk.Sheets(1).Cells(i,3).Value
wkbk.Sheets(1).Cells(i,2).Formula = wkbk.Sheets(1).Cells(i,4).Value
Next i
Application.ScreenUpdating = True

Also, I don't know how long the actual file will be, so I'm almost forced to assume 65535...

View Replies!   View Related
Removing An Added Space
Our system, when displaying times adds a space before the time, space05:14:15 - space14:56:39, When I use this formula, =(F292-E292+(F292<E292))*24-0.5, to figure out hours worked, it does not work. If I remove the space, the formula works fine. Is there an easy way to automatically remove the space instead of having to do it manually?

View Replies!   View Related
Locate 2nd Space From Right And Truncate
This formula finds the last space from the right and returns the values less the last space and whatever is to the right-
=TRIM(IF(LEFT(Y25,2)="~C",REPLACE(LEFT(Y25,FIND("`",SUBSTITUTE(Y25," ","`",LEN(Y25)-LEN(SUBSTITUTE(Y25," ",""))))),1,FIND(" ",Y25),""),RIGHT(Y25,LEN(Y25)-FIND(" ",Y25))))

Results of a item of a whole size:

However- I forgot I had added a criteria to convert records that have a fractional value from decimal to a fractional value and an extra space shows up. I need to alter the above formula to handle this additional condition, returning the value w/ out the second space and the size 10 shown below.

Results of an item w/ a fractional size, ie. 10 1/2:


Linked to this post: new post started to help avoid confusion: but wanted to show prior material...

View Replies!   View Related
How To Remove Space From A Cell
some vale in the column where i do a vlookup to get data

but i have some problem the vlaue in the cells contains space at the end and i am not able to remove i tried TRIM and also text to column but it does not work



View Replies!   View Related
Insert A Space In A Postcode
I'm trying to find a formula that will put a space in the correct place in a British postcode.

I have a column I need to sort this way. Some of the postcodes already have the correct space and others don't.

British postcodes can be in several formats......

n = a letter
1 = a number

n11 1nn
n1 1nn
n1 1n
n1n 1n
n1n 1nn
n11n 1n
n11n 1nn
nn1 1nn
nn1 1n
nn11 1nn
nn11 1n

On a side note I need to make all the text uppercase. In the column some already have uppercase and others don't.

View Replies!   View Related
Copy Column With A Space Row
I would like a macro to copy the data in Raw1 and Raw2 from sheet1 into sheet2. but with a space row between data as shown in attrachement.

the number of rows in Raw1 and Raw2 is always the same. but the number of rows can be very big and unknown.

I have named the title of Raw1 as "raw". becasue I want the macro will still work when I insert a column before it.

View Replies!   View Related
Blank Space At End Of Cell
in my workbook I have a list of names. Some of these names have a blank space at the end of them. How do I get rid of that blank space? Basically, it might say:

John Brown
Fred Basset
Fred Jones
Ian Smith
Ian O'Donnell
Adam Simpson

And if you put your cursor at the end of each of those names, you'll see that some have a blank space at the end, and some don't. How do I trim this blank space away from the end?

View Replies!   View Related
Finding The Last Space In A String
there is AT() which finds the first occurrence of a string searching from the left like FIND() and SEARCH(), and RAT() which finds the first occurrence searching from the right-to-left.

A single column with names:
John Doe
Jane Marie Smith
Dr. Alex R. Jones

I need two columns that would look like:
Jane Marie........Smith
Dr. Alex R.........Jones

View Replies!   View Related
Copyright © 2005-08, All rights reserved