LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Nooby
 
Posts: n/a
Default Why does this function NOT return a value?

The msgbox in the "strip" function below has a good value.
But when I check it in the " MsgBox "after strip comp1=" & comp1 & ",
comp2=" & comp2
" box, there is no value. Any help would be greatly appreciated.
Sam


Sub compare_output()
Dim str1 As String
Dim str2 As String
Dim comp1 As String
Dim comp2 As String
r = 1
Dim lastrow As Long, i As Long
ActiveSheet.UsedRange
With Cells.SpecialCells(xlCellTypeLastCell)
lastrow = .Row
End With

For i = 1 To lastrow
str1 = ActiveSheet.Cells(r, 1)
str2 = ActiveSheet.Cells(r, 2)
MsgBox "str1=" & str1 & ", str2=" & str2
comp1 = strip(str1)
comp2 = strip(str2)
MsgBox "after strip comp1=" & comp1 & ", comp2=" & comp2
If (comp1 < comp2) Then
XColor = 5
Else
XColor = 7
End If

If (XColor) Then
Range(ActiveSheet.Cells(r, 1), ActiveSheet.Cells(r, 2)).Select
With Selection.Interior
.ColorIndex = XColor
.Pattern = xlSolid
End With
End If
r = r + 1

Next
End Sub

Function strip(chars)
Dim buff As String
buff = " "
For i = 1 To Len(chars)
If Mid(chars, i, 1) " " Then
buff = buff & Mid(chars, i, 1)
End If
Next i
MsgBox "buff=" & buff
End Function

 
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
Custom functions calculating time arguments Help Desperate Bill_De Excel Worksheet Functions 12 April 25th 06 02:22 AM
VLookUp function to return multiple rows sebastian stephenson Excel Worksheet Functions 7 April 20th 06 06:25 PM
Can a function return a Null (blank ) value? Maybe a custom functi colin_e Excel Worksheet Functions 2 March 16th 06 02:36 PM
Function to check list for specific conditions and return an answe tanya Excel Discussion (Misc queries) 2 July 6th 05 11:43 AM
Error Return Value from and INDEX(A:2,MATCH()) function BJ Excel Worksheet Functions 4 January 26th 05 02:59 PM


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