嘿家伙/ gals,在VB中遇到一些麻烦,我从Excel中读取字符串并将它与另一个字符串进行比较,当我看到MSGBox时,它们看起来相同,但VB没有认识到他们是一样的,它一直在让我感谢。当两个字符串相同但不相同时,尽管它们是相同的
Sub runit()
Dim indicator As Integer
Dim actual As String
Dim tmp As String
tmp = "3. AIRCRAF"
Sheets("Sheet2").Select
For i = 3 To 1200
actual = Left(Cells(i, 1).Text, 10)
If i = 203 Then
MsgBox actual & tmp
End If
If actual = tmp Then
MsgBox i
Cells(i, 1).Select
ActiveCell.Range("A1:M997").Select
Selection.Copy
Sheets("Sheet3").Select
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
tmp = "zzZZxxXXedc"
End If
Next
Sheets("Sheet3").Select
tmp = "H."
indicator = 0
For j = 1 To 600
If tmp = actual Then
indicator = 1
Cells(j, 1).Select
tmp = "zzZZxxXXedc"
ActiveCell.Range("A1:M1200").Select
Selection.ClearContents
Cells(1, 1).Select
End If
Next
If indicator = 0 Then
actual = Left(Cells(j, 1).Value, 2)
Rows(j + 1).Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
End If
End Sub