dhananjay
12-17-2008, 07:42 AM
I know it is a very simple syntax error... but I am not getting it right...
I am getting a type mismatch error in the if statement for the following code...
Sub separateFiles()
Dim rng As Range, arr As Variant
Dim i As Integer
Dim bSubString As Boolean
Dim str1, str2, str3 As String
Dim asmrow, prtrow, drwrow, row As Integer
str1 = "asm"
str2 = "prt"
str3 = "drw"
asmrow = 32
prtrow = 32
drwrow = 32
Set rng = Worksheets("Sheet1").Range("A32:A100")
arr = Application.Transpose(rng.Value)
For i = LBound(arr) To UBound(arr)
'asmB = InStr(arr, str1)
If bSubString = InStr(arr, str1) <> 0 Then ' this line gives an error..
Cells(asmrow, 32).Value = arr
asmrow = asmrow + 1
End If
If InStr(arr, str2) <> 0 Then
Cells(prtrow, 32).Value = arr
prtrow = prtrow + 1
End If
If InStr(arr, str3) <> 0 Then
Cells(drwrow, 32).Value = arr
drwrow = drwrow + 1
End If
Next i
End Sub
I am getting a type mismatch error in the if statement for the following code...
Sub separateFiles()
Dim rng As Range, arr As Variant
Dim i As Integer
Dim bSubString As Boolean
Dim str1, str2, str3 As String
Dim asmrow, prtrow, drwrow, row As Integer
str1 = "asm"
str2 = "prt"
str3 = "drw"
asmrow = 32
prtrow = 32
drwrow = 32
Set rng = Worksheets("Sheet1").Range("A32:A100")
arr = Application.Transpose(rng.Value)
For i = LBound(arr) To UBound(arr)
'asmB = InStr(arr, str1)
If bSubString = InStr(arr, str1) <> 0 Then ' this line gives an error..
Cells(asmrow, 32).Value = arr
asmrow = asmrow + 1
End If
If InStr(arr, str2) <> 0 Then
Cells(prtrow, 32).Value = arr
prtrow = prtrow + 1
End If
If InStr(arr, str3) <> 0 Then
Cells(drwrow, 32).Value = arr
drwrow = drwrow + 1
End If
Next i
End Sub