Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Extracting a number from a multiline-entry

Dear Experts:

I would like to extract a number from multi-line excel cells. The
cells have the following make-up


123456(manual line break = Alt+Enter)
sample text (manual line break = Alt+Enter)
sample text

In the above example I would like to extract the number located
immediately before the first manual line break and display it in a
separate cell. Can this be done using a formula/function?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Extracting a number from a multiline-entry

On Mon, 22 Mar 2010 02:27:28 -0700 (PDT), andreashermle
wrote:

Dear Experts:

I would like to extract a number from multi-line excel cells. The
cells have the following make-up


123456(manual line break = Alt+Enter)
sample text (manual line break = Alt+Enter)
sample text

In the above example I would like to extract the number located
immediately before the first manual line break and display it in a
separate cell. Can this be done using a formula/function?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas


If the format is exactly as you post, with ONLY the number on the line prior to
the first manual line-break, then:

=LEFT(A1,FIND(CHAR(10),A1)-1)

will return that string of numbers as a text string, or:

--=LEFT(A1,FIND(CHAR(10),A1)-1)

to return it as a number.

Note that the manual line break character is ASCII code 10.

--ron
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Extracting a number from a multiline-entry

On Mon, 22 Mar 2010 02:27:28 -0700 (PDT), andreashermle
wrote:

Dear Experts:

I would like to extract a number from multi-line excel cells. The
cells have the following make-up


123456(manual line break = Alt+Enter)
sample text (manual line break = Alt+Enter)
sample text

In the above example I would like to extract the number located
immediately before the first manual line break and display it in a
separate cell. Can this be done using a formula/function?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas



And since this question is in a programming group, the equivalent VBA
expression could be:


Left(Range("a1"), InStr(Range("a1"), Chr(10)) - 1)

or even:

Split(Range("a1"), Chr(10))(0)

--ron
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Extracting a number from a multiline-entry

Hi,

Like this

=LOOKUP(6.022*10^23,--LEFT(A1,ROW(INDIRECT("1:"&LEN(A1)))))

or if there could be a leading zero you want to retain the slightly longer

=LEFT(A1,SUMPRODUCT(--ISNUMBER(-MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))))

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"andreashermle" wrote:

Dear Experts:

I would like to extract a number from multi-line excel cells. The
cells have the following make-up


123456(manual line break = Alt+Enter)
sample text (manual line break = Alt+Enter)
sample text

In the above example I would like to extract the number located
immediately before the first manual line break and display it in a
separate cell. Can this be done using a formula/function?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Extracting a number from a multiline-entry

I would like to extract a number from multi-line excel cells. The
cells have the following make-up


123456(manual line break = Alt+Enter)
sample text (manual line break = Alt+Enter)
sample text

In the above example I would like to extract the number located
immediately before the first manual line break and display it in a
separate cell. Can this be done using a formula/function?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas



And since this question is in a programming group, the equivalent VBA
expression could be:


Left(Range("a1"), InStr(Range("a1"), Chr(10)) - 1)

or even:

Split(Range("a1"), Chr(10))(0)


Or possibly even....

Val(Range("A1"))

as long as the number is either a whole number or a floating point number
that uses a dot for its decimal point.

--
Rick (MVP - Excel)



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Extracting a number from a multiline-entry

On Mon, 22 Mar 2010 09:26:20 -0400, "Rick Rothstein"
wrote:

Or possibly even....

Val(Range("A1"))

as long as the number is either a whole number or a floating point number
that uses a dot for its decimal point.


I haven't tested that but would that not remove the opportunity to retain
leading zero's?
--ron
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Extracting a number from a multiline-entry

On 22 Mrz., 11:17, Ron Rosenfeld wrote:
On Mon, 22 Mar 2010 02:27:28 -0700 (PDT), andreashermle
wrote:





Dear Experts:


I would like to extract a number from multi-line excel cells. The
cells have the following make-up


123456(manual line break = Alt+Enter)
sample text (manual line break = Alt+Enter)
sample text


In the above example I would like to extract the number located
immediately before the first manual line break and display it in a
separate cell. Can this be done using a formula/function?


Help is much appreciated. Thank you very much in advance.


Regards, Andreas


If the format is exactly as you post, with ONLY the number on the line prior to
the first manual line-break, then:

=LEFT(A1,FIND(CHAR(10),A1)-1)

will return that string of numbers as a text string, or:

--=LEFT(A1,FIND(CHAR(10),A1)-1)

to return it as a number.

Note that the manual line break character is ASCII code 10.

--ron- Zitierten Text ausblenden -

- Zitierten Text anzeigen -


HI Ron,

great, thank you very much for your professional help. It works as
desired. Regards, Andreas
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Extracting a number from a multiline-entry

Or possibly even....

Val(Range("A1"))

as long as the number is either a whole number or a floating point number
that uses a dot for its decimal point.


I haven't tested that but would that not remove the opportunity to retain
leading zero's?


Yes, that is true, Val returns a number, not a String, so any formatting
would be lost. However, I would point out that the OP referred to it as a
"number" twice in her original posting, so I went with that. If leading
zeroes were required, then how many digits in the number would more than
likely be known (6 digits for the example the OP gave), so this could be
used if that was the requirement...

Format(Val(Range("A1")), "00000")

--
Rick (MVP - Excel)

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Extracting a number from a multiline-entry

On Mar 22, 6:29*pm, "Rick Rothstein"
wrote:
Or possibly even....


Val(Range("A1"))


as long as the number is either a whole number or a floating point number
that uses a dot for its decimal point.


I haven't tested that but would that not remove the opportunity to retain
leading zero's?


Yes, that is true, Val returns a number, not a String, so any formatting
would be lost. However, I would point out that the OP referred to it as a
"number" twice in her original posting, so I went with that. If leading
zeroes were required, then how many digits in the number would more than
likely be known (6 digits for the example the OP gave), so this could be
used if that was the requirement...

Format(Val(Range("A1")), "00000")

--
Rick (MVP - Excel)


Hi Rick,

thank you very much for your terrific support. The formula for my
problem provided by Ron is the best solution for me. Although your
code snippet is handy for another problem I am having. Thank you very
much. Regards, Andreas
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Extracting a number from a multiline-entry

On Mon, 22 Mar 2010 10:10:57 -0700 (PDT), andreashermle
wrote:

HI Ron,

great, thank you very much for your professional help. It works as
desired. Regards, Andreas


Glad to help.

Thanks for the feedback.
--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text parsing - Extracting data from inconsistent data entry format. u473 Excel Programming 2 August 26th 07 01:51 AM
Multiline textbox for data entry אלי Excel Programming 2 June 12th 07 11:50 AM
Extracting first two digits of a time entry!! roshinpp_77[_20_] Excel Programming 4 August 8th 06 01:29 PM
Help!!! Extracting a number to line up with a different number lpdc Excel Discussion (Misc queries) 4 June 13th 06 08:40 PM
Extracting text from a cell entry morchard Excel Discussion (Misc queries) 2 July 6th 05 03:53 PM


All times are GMT +1. The time now is 10:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"