What am i trying to do??
Say there are 10 bags on the floor. Each bag contains a mixture of fruits in them.
I only want the bags which contain a mixture of apple,banana and pineapple the rest i want to ignore.
eg: say one bag contains apple,banana and peach i will ignore the bag, but say one bag has apple,banana and pineapple,
i will take the bag.
IN EXCEL:
copy the cells from sheet 1 which contains the exact data(apple,banana,pineapple) along with qty and paste it in sheet 2.
IF i try this code the computer just hangs for some reason for 2 mins
and then gives me the error: "run type error 13 type mismatch"
HERE IS THE CODE THAT I TRIED
i am very new to this type of coding please let me know as to what went wrong.
Thanks.
Say there are 10 bags on the floor. Each bag contains a mixture of fruits in them.
I only want the bags which contain a mixture of apple,banana and pineapple the rest i want to ignore.
eg: say one bag contains apple,banana and peach i will ignore the bag, but say one bag has apple,banana and pineapple,
i will take the bag.
IN EXCEL:
copy the cells from sheet 1 which contains the exact data(apple,banana,pineapple) along with qty and paste it in sheet 2.
IF i try this code the computer just hangs for some reason for 2 mins
and then gives me the error: "run type error 13 type mismatch"
HERE IS THE CODE THAT I TRIED
Code:
Sub compile_One()
i = 1
j = 0
'k = 1
For i = 1 To 2
'If Worksheets(1).Cells(rows, 1).Value = "" Then
'Exit For
'Else
If Worksheets(1).Range("a" & i).Value = "apple" Then
'k = i
j = i
i = i + 1
Else
End If
'Next i 'GIVES AN ERROR DONT KNOW WHY???
'Exit For
If Worksheets(1).Range("a" & i).Value = "banana" Then
i = i + 1
Else
End If
'Next i
'Exit For
If Worksheets(1).Range("a" & i).Value = "pineapple" Then
'End If
'For j = j To 10
Worksheets(2).Range(Rows, 1).Value = Worksheets(1).Range("a" & j).Value 'HANGS HERE USE F8 TO SEE
Worksheets(2).Range(Rows, 1).Value = Worksheets(1).Range("b" & j).Value
j = j + 1
Worksheets(2).Range(Rows, 1).Value = Worksheets(1).Range("a" & j).Value
Worksheets(2).Range(Rows, 1).Value = Worksheets(1).Range("b" & j).Value
j = j + 1
Worksheets(2).Range(Rows, 1).Value = Worksheets(1).Range("a" & j).Value
Worksheets(2).Range(Rows, 1).Value = Worksheets(1).Range("b" & j).Value
Else
End If
'Exit For
Next i
End Sub
i am very new to this type of coding please let me know as to what went wrong.
Thanks.