LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 62
Default Finding Number Inside a Cell

Alright, I was able to make a little bit of progress.

I created a function which gets the cell value as a string, reverses
the string, and finds the items before the first space (which since
the string is reversed refer to the last items of the original
string).

Thus I can get 5.3, +-6, and +4/-2.

Next up -

How to convert a string into a number (this is probably easily
searched on the archives).

How to make a function which identifies if the first portion of the
string is the +- symbol, and then remove it and give me the number 6.

How to make a function which if the above isn't satisfied, then
assumes the form of the tolerance is +X/-Y (where Y can equal 0 and
there will be no - sign), and finds X and Y. The tricky part here is
sometimes there will be a Y, sometimes not.

The code below is what I'm using so far. Ways to make it cleaner of
course appreciated:


Sub ReConfirmVariableVariances()

Dim TeishutsuItemRow As Long
Dim TeishutsuItemColumn As Long
Dim PrevXTIR As Long
Dim SokuteiPointNumber As Long
Dim SolutionTolerance As Long
Dim ToleranceValue As String
Dim XYLCounter As Long
Dim TempLoop As Long



' SET THE VARIABLES FOR TEISHUTSUROW AND COLUMN.
TeishutsuItemRow = 3
TeishutsuItemColumn = 8
SokuteiPointNumber = 1
PrevXTIR = 0

Do Until SokuteiPointNumber = 51

For TempLoop = 1 To 1

If Sheets("提出用").Cells(TeishutsuItemRow, TeishutsuItemColumn +
1).Value = SokuteiPointNumber Then
If Sheets("提出用").Cells(TeishutsuItemRow, TeishutsuItemColumn +
2).Value = "" Then
TempLoop = 2
TeishutsuItemRow = PrevXTIR
Else
TempLoop = 2
End If
Else
TeishutsuItemRow = TeishutsuItemRow + 1
End If

TempLoop = TempLoop - 1

Next TempLoop

For XYLCounter = 0 To 2

ToleranceString = Sheets("提出用").Cells(TeishutsuItemRow,
TeishutsuItemColumn + XYLCounter + 2).Value
ToleranceValue = LastNumber(ToleranceString)
MsgBox "ToleranceValue = " & (ToleranceValue)


Next XYLCounter



PrevXTIR = TeishutsuItemRow
TeishutsuItemRow = TeishutsuItemRow + 1
SokuteiPointNumber = SokuteiPointNumber + 1
Loop


End Sub


Function LastNumber(ToleranceString) As String
Dim Newstring As String
Dim SpacePlace As Integer
Dim RevOut As String
Newstring = StrReverse(ToleranceString)
SpacePlace = InStr(1, Newstring, " ")
RevOut = Left(Newstring, SpacePlace - 1)
LastNumber = StrReverse(RevOut)
End Function



On 7月15日, 午前10:03, pallaver wrote:
I don't know enough about VBA yet to do this without help.

I have a column of variable tolerances which have one of the following
forms:

5 ST 5.3 (aka number, space, "ST", space, desired number)
5 +-6 (aka number, space, +- symbol, another numberm)
5 +4/-2 (aka number, space, positive number, /, negative number)

I need to be able to extract the tolerance numbers in order to use
them for conditional formatting.

I would want the following from the above:
5.3 (there is a set tolerance off this number, so all I need is this
number, I don't need 5 at all).
5 and 6 to turn into -1 to 11 (the max/min of the tolerance).
5, 4, and -2 to turn into 3 to 9 (the max/min of the tolerance).

This surely involves finding spaces, /, etc., and determining what is
what, but I'm having a lot of trouble getting things to work in VBA.

Suggestions and existing code to improve much appreciated.

Thanks, NP


 
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
Finding Cell that changes from a Positive to a Negitive number tpeter Excel Worksheet Functions 2 December 12th 07 06:27 PM
Sum x number of right cells after finding first cell more than 0. Learn Excel Worksheet Functions 4 December 9th 07 04:57 PM
Finding the Row number based on contents of a cell Chris Youlden Excel Worksheet Functions 5 September 6th 07 04:38 PM
finding a particular cell in another worksheet whose row number ch Andrew Excel Discussion (Misc queries) 1 September 12th 05 01:36 PM
Page Number inside Cell? mae1778 Excel Discussion (Misc queries) 3 August 13th 05 09:34 PM


All times are GMT +1. The time now is 01:37 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"