View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
pallaver pallaver is offline
external usenet poster
 
Posts: 62
Default Finding Number Inside a Cell

Note here that with Rick's solution, I hadn't put in conditional
formatting yet.
This is really quite easy, the tough part was getting the max/min (or
high/low) to get a correct readout.

I still need to sit down and look at the code to understand it. Maybe
I'll try to think of some similar type program to write and try out to
test myself afterwards. Regardless, in the future a question or two
may come, but for now, here's Rick's solution laid out.

------ Rick's SOLUTION Style --------
Sub RCVV_WP()


Dim TeishutsuItemRow As Long
Dim TeishutsuItemColumn As Long
Dim PrevXTIR As Long
Dim PrevYTIR As Long
Dim PrevLTIR As Long
Dim SokuteiPointNumber As Long
Dim HighestPointNumber As Long
Dim SolutionTolerance As Long
Dim ToleranceString As String
Dim ToleranceValue As String
Dim LValueBase As String
Dim TempLoop As Long
Const Separator1 = "/"
Const Separator2 = "±"
Const StanleyText = " ST "
Const NumericCharacters = "+-0123456789"
Dim Position As Integer
Dim High As String
Dim Low As String



' SET THE VARIABLES FOR TEISHUTSUROW AND COLUMN.
' ALSO SET PREVIOUS X,Y,L ITEM ROWS IN THE EVENT REPEATED (BLANK)
TOLERANCE ENTRY.
' SOKUTEI AND HIGHEST POINT NUMBERS SET TO 1.
TeishutsuItemRow = 3
TeishutsuItemColumn = 8
PrevXTIR = 0
PrevYTIR = 0
PrevLTIR = 0
SokuteiPointNumber = 1
HighestPointNumber = 1

For TempLoop = 3 To 300
If Sheets("提出用").Cells(TempLoop, TeishutsuItemColumn + 1).Value
HighestPointNumber Then
HighestPointNumber = Sheets("提出用").Cells(TempLoop,
TeishutsuItemColumn + 1).Value
End If
Next TempLoop

'MsgBox "HighestPointNumber = " & (HighestPointNumber)

' LOOP FOR ALL SOKUTEI POINTS.
Do Until SokuteiPointNumber = HighestPointNumber + 1

' RESET VALUES FOR TOLERANCE
ToleranceValue = ""


' FIRST MATCH UP SOKUTEI POINT WITH ROW ON 提出用 SHEET, AND SOLVE FOR
XYL TOLERANCES.
For TempLoop = 0 To 2

ToleranceString = Sheets("提出用").Cells(TeishutsuItemRow,
TeishutsuItemColumn + 2 + TempLoop).Value

MsgBox "ToleranceString = " & (ToleranceString)

High = MaxTol(ToleranceString)
Low = MinTol(ToleranceString)

MsgBox "High = " & (High)
MsgBox "Low = " & (Low)

Next TempLoop


Loop

End Sub

Function MaxTol(VarTol As String) As Variant
Dim Parts() As String
On Error GoTo BadFormat
If VarTol Like "* [Ss][Tt] *" Then
MaxTol = CDbl(Split(VarTol, "ST", , vbTextCompare)(1))
Exit Function
End If
If VarTol Like "* ±*" Then
Parts = Split(VarTol, "±")
MaxTol = CDbl(Parts(0)) + CDbl(Parts(1))
Exit Function
End If
If VarTol Like "* */*" Then
MaxTol = CDbl(Split(VarTol)(0)) + CDbl(Split(Split(VarTol)(1), "/")
(0))
Exit Function
End If
BadFormat:
MaxTol = "#BADFORMAT!"
End Function


Function MinTol(VarTol As String) As Variant
Dim Parts() As String
On Error GoTo BadFormat
If VarTol Like "* [Ss][Tt] *" Then
MinTol = CDbl(Split(VarTol, "ST", , vbTextCompare)(1))
Exit Function
End If
If VarTol Like "* ±*" Then
Parts = Split(VarTol, "±")
MinTol = CDbl(Parts(0)) - CDbl(Parts(1))
Exit Function
End If
If VarTol Like "* */*" Then
MinTol = CDbl(Split(VarTol)(0)) + CDbl(Split(Split(VarTol)(1), "/")
(1))
Exit Function
End If
BadFormat:
MinTol = "#BADFORMAT!"
End Function