close

The msgbox in the quot;stripquot; function below has a good value.
But when I check it in the quot; MsgBox quot;after strip comp1=quot; amp; comp1 amp; quot;,
comp2=quot; amp; comp2
quot; box, there is no value. Any help would be greatly appreciated.
SamSub 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 quot;str1=quot; amp; str1 amp; quot;, str2=quot; amp; str2
comp1 = strip(str1)
comp2 = strip(str2)
MsgBox quot;after strip comp1=quot; amp; comp1 amp; quot;, comp2=quot; amp; comp2
If (comp1 lt;gt; 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 = quot; quot;
For i = 1 To Len(chars)
If Mid(chars, i, 1) gt; quot; quot; Then
buff = buff amp; Mid(chars, i, 1)
End If
Next i
MsgBox quot;buff=quot; amp; buff
End FunctionStrip is never set in the function of the same name.
--
Gary''s Studentquot;Noobyquot; wrote:

gt; The msgbox in the quot;stripquot; function below has a good value.
gt; But when I check it in the quot; MsgBox quot;after strip comp1=quot; amp; comp1 amp; quot;,
gt; comp2=quot; amp; comp2
gt; quot; box, there is no value. Any help would be greatly appreciated.
gt; Sam
gt;
gt;
gt; Sub compare_output()
gt; Dim str1 As String
gt; Dim str2 As String
gt; Dim comp1 As String
gt; Dim comp2 As String
gt; r = 1
gt; Dim lastrow As Long, i As Long
gt; ActiveSheet.UsedRange
gt; With Cells.SpecialCells(xlCellTypeLastCell)
gt; lastrow = .Row
gt; End With
gt;
gt; For i = 1 To lastrow
gt; str1 = ActiveSheet.Cells(r, 1)
gt; str2 = ActiveSheet.Cells(r, 2)
gt; MsgBox quot;str1=quot; amp; str1 amp; quot;, str2=quot; amp; str2
gt; comp1 = strip(str1)
gt; comp2 = strip(str2)
gt; MsgBox quot;after strip comp1=quot; amp; comp1 amp; quot;, comp2=quot; amp; comp2
gt; If (comp1 lt;gt; comp2) Then
gt; XColor = 5
gt; Else
gt; XColor = 7
gt; End If
gt;
gt; If (XColor) Then
gt; Range(ActiveSheet.Cells(r, 1), ActiveSheet.Cells(r, 2)).Select
gt; With Selection.Interior
gt; .ColorIndex = XColor
gt; .Pattern = xlSolid
gt; End With
gt; End If
gt; r = r 1
gt;
gt; Next
gt; End Sub
gt;
gt; Function strip(chars)
gt; Dim buff As String
gt; buff = quot; quot;
gt; For i = 1 To Len(chars)
gt; If Mid(chars, i, 1) gt; quot; quot; Then
gt; buff = buff amp; Mid(chars, i, 1)
gt; End If
gt; Next i
gt; MsgBox quot;buff=quot; amp; buff
gt; End Function
gt;
gt;

Sorry, but I am new to this and I'm working as a fill in on a real
project.
I don't understand your answer. How do I set it?Function strip(chars)
Dim buff As String
buff = quot; quot;
For i = 1 To Len(chars)
If Mid(chars, i, 1) gt; quot; quot; Then
buff = buff amp; Mid(chars, i, 1)
End If
Next i
MsgBox quot;buff=quot; amp; buff
strip=buff
End FunctionNote the added last statement before the End Function

--
Gary''s Studentquot;Noobyquot; wrote:

gt; Sorry, but I am new to this and I'm working as a fill in on a real
gt; project.
gt; I don't understand your answer. How do I set it?
gt;
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()