MrExcel Publishing
Your One Stop for Excel Tips & Solutions

The lunatics are on the cell


Posted by Dani on September 21, 2001 10:19 AM

Hi one more time. Here the newbie.
I'm trying to use the "like" operator to get compare the text of a cell
in a worksheet and if it does match, copy that cell into another workshee's cell.
This is what I'm doing:

Private Sub print_cmd_Click()
Dim i As Integer
Dim a As Integer
Dim anystr As String
anystr = print_frm.cat_cbo.Value


For i = 9 To 804



If anystr Like "Sit*" Then
For a = 6 To 100
If Range("B" & a).Value = "" Then
Worksheets("SubTotal").Range("b" & a) = Worksheets("Information").Range("b" & i).Value
End If
Next a
End If

But looks like does not copying anything.
Am I doing something wrong?

Thanks a lot

dani

Next i


Posted by Ivan F Moala on September 21, 2001 11:59 AM

Not sure BUT....

By default the like statement is doing a comaparison
by internal binary representations of the characters code page (Language version) or more simply
it is case sensitive, so Sit is NOT like sit.
To do a Non case sensitive match try setting
in your declarations area;
Option compare text


does this help any ??


Ivan

If anystr Like "Sit*" Then For a = 6 To 100 If Range("B" & a).Value = "" Then Worksheets("SubTotal").Range("b" & a) = Worksheets("Information").Range("b" & i).Value End If Next a End If But looks like does not copying anything.

Posted by Dani on September 21, 2001 12:01 PM

THANKS IVAN, it's working now.