Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default two question?

I have text which is imported into a spreadsheet.

All the text is in an individual cell but within that text will be a value
that i want to capture.

for examle

"the selling price for this is £2.99 and the product code is 123456"

i have similar text going down in column A for about 120 rows?

the value i want is the price being £2.99, i can't use the left, right or
mid function as the length of the text can be any length.

Is there another function i can use that can pick up this value?

i'm trying to write a macro that will pick up this value and use it for
further calulations.

Next question

If i want a macro to stop running and close excel completely without saving
the spreadsheet what is the code for this?

for example

if activecell.value = "" then
close excel??

thank you in advance

hervinder


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default two question?


1. "the selling price for this is £2.99 and the product code is 123456"

=LEFT(MID(A2,SEARCH("L",A2)+1,256),SEARCH(" ",MID(A2,SEARCH("L",A2)+1,256))-1)


2. if activecell.value = "" then
ThisWorkbook.Saved = True
Application.Quit
End if

Please, next time post different questions in separate messages!

Regards,
Stefi

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default two question?

1. This will return the amounts from the sentence:

Function GetAmounts(ByVal Sentence As String) As Variant
Digits = "0123456789 " & "." ' Application.DecimalSeparator
Sentence = Replace(Sentence, ",", "") ' Thousand separators
For i = 1 To Len(Sentence)
Select Case InStr(Digits, Mid(Sentence, i, 1))
Case Is = 0
Mid(Sentence, i, 1) = " "
End Select
Next
GetAmounts = Trim(Sentence)
Do Until 0 = InStr(GetAmounts, " ")
GetAmounts = Replace(GetAmounts, " ", " ")
Loop
GetAmounts = Split(GetAmounts, " ")
End Function

Sub xx()
xy = GetAmounts("the selling price for this is £2.99 and the product
code is 123456")
End Sub

?xy(0)
2.99
?xy(1)
123456
?ubound(xy) ' Add 1 to this- split use Option Base 0 regardless of your
setting
1

2. ActiveWorkbook.Saved = True
Application.Quit

"Hervinder" wrote:

I have text which is imported into a spreadsheet.

All the text is in an individual cell but within that text will be a value
that i want to capture.

for examle

"the selling price for this is £2.99 and the product code is 123456"

i have similar text going down in column A for about 120 rows?

the value i want is the price being £2.99, i can't use the left, right or
mid function as the length of the text can be any length.

Is there another function i can use that can pick up this value?

i'm trying to write a macro that will pick up this value and use it for
further calulations.

Next question

If i want a macro to stop running and close excel completely without saving
the spreadsheet what is the code for this?

for example

if activecell.value = "" then
close excel??

thank you in advance

hervinder


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default two question?

Copying changed £ the pound sign to L, the correct formula is:

=LEFT(MID(A2,SEARCH("£ ",A2)+1,256),SEARCH(" ",MID(A2,SEARCH("£
",A2)+1,256))-1)


Stefi

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
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good davegb Excel Programming 1 May 6th 05 06:35 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 27th 05 07:46 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 22nd 05 03:30 PM


All times are GMT +1. The time now is 04:26 PM.

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

About Us

"It's about Microsoft Excel"