View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Martin Fishlock Martin Fishlock is offline
external usenet poster
 
Posts: 694
Default Finding MAX Value of Part of Cell Contents

Corey:

This function will find the value for you. You then have to add one to it
and put it in the text box.

Function findmax() As Long
Const iColumn As Integer = 5 ' column to use
Const iCharsToIgnore As Integer = 3 ' chars to ignore at start
Dim ws As Worksheet
Dim lRowStart As Long, lRowEnd As Long
Dim rCell As Range
Dim lMax As Long ' from spec no -ve values and only integers lmax
default 0 ok
Dim lCur As Long ' current number
' set sheet to use
Set ws = ActiveSheet

'find first and last rows
lRowStart = ws.UsedRange.Row
lRowEnd = ws.UsedRange.Rows.Count + lRowStart - 1
On Error Resume Next ' catch errors
For Each rCell In Range(Cells(lRowStart, iColumn), Cells(lRowEnd,
iColumn))
If rCell < "" Then
' on error uses last value ok may want better error checking
lCur = Right(rCell.Value, Len(rCell.Value) - iCharsToIgnore)
If lCur lMax Then lMax = lCur
End If
Next rCell
findmax = lMax
End Function

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Corey" wrote:

I have a list of values in :
Sheet8.Range("E:E")
that are formatted as:
ST 1234 ' IE "ST_1234" where "_" = Space

I want to place the Maximum Numerical Value +1 into a Textbox on a Userform,
But to date i have yet worked out how to manage it?

Any One assist me ?
Corey....