|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
The function findnth() works fine for my purposes of finding a cell against a specified range and returning a result value if val1 is an exact match. But I need to strip some extra characters out and can't get the function extractroomnumber to work using the following statement (see # below):
If ExtractRoomNumber(Table.Cells(i, SearchCol).Text) = Val1.Text Then .... Shouldn't this take the text of table.cells, strip off the extra I don't want and evaluate it against the arguement val1? For instance if val1 = "11-386" and table.cells(i.searchcol.text) = "11-386 blah, blah, blah", then I'd want this True. Help? Thanks, Michael *********************************************** Function FindNth(Table As Range, Val1 As Variant, SearchCol As Integer, Val1Occrnce As Integer, ResultCol As Integer) Dim i As Integer Dim iCount As Integer Dim rCol As Range Dim tmp As String For i = 1 To Table.Rows.Count # If Table.Cells(i, SearchCol).Text = Val1.Text Then iCount = iCount + 1 End If If iCount = Val1Occrnce Then FindNth = Table.Cells(i, ResultCol) Exit For End If Next i End Function ------------------------------------------------------------------ Function ExtractRoomNumber(roomnumber As String) Dim startpos As Integer startpos = InStr(roomnumber, " ") If startpos > 0 Then ExtractRoomNumber = Left$(roomnumber, startpos - 1) Else ExtractRoomNumber = roomnumber End If End Function |
|
#2
|
|||
|
|||
|
I have read your code,but i can't find obvious error...U should print the return value of the function ExtractRoomNumber to check it..Or add the type of resturn value:Function ExtractRoomNumber(roomnumber As String)
as string It's my advice for you.. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Function problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|