sljivan
09-26-2013, 05:21 AM
Hello guys. I am new at this and what I am trying to do is make a program which will read cells one by one and check if there is a character in it.
e.g.
we have something like this:
A
B
C
D
E
1
ABC
DEF
GHI
JKL
MNO
2
0
0
0
0
0
and we want to read the cells and underneath them write a digit if there an K in the cell.
My code is:
Sub searchForK()
Dim cell As String
For i = 1 To 5
cell = Cells(1, i)
Cells(2, i) = InStr(1, K, cell, vbTextCompare)
Next i
End Sub
And what I get is all zeros... even though in the D2 cell there is an K. And it should have written 2. Right?
So what did I do wrong?
Thank you!
e.g.
we have something like this:
A
B
C
D
E
1
ABC
DEF
GHI
JKL
MNO
2
0
0
0
0
0
and we want to read the cells and underneath them write a digit if there an K in the cell.
My code is:
Sub searchForK()
Dim cell As String
For i = 1 To 5
cell = Cells(1, i)
Cells(2, i) = InStr(1, K, cell, vbTextCompare)
Next i
End Sub
And what I get is all zeros... even though in the D2 cell there is an K. And it should have written 2. Right?
So what did I do wrong?
Thank you!