this is my code:
I'm using the code to run an inventory I have a list of serial numbers of items i should have on hand
in col B. col A is blank for now. and i use Cell H1 as my entry point if you will. C-G have other stuff in them.
this is essentially what it looks like to begin with
34
76
89
56
02
69
101
75
200
369
I enter a number into H1, it searches col B if finds a match it places it into coresponding cell in Col A, if no match it places into H3, either way H1 resets and awaits the next entry. Subsequent non-matches just continue down col H.
A B H
3 (this is where i enter numbers)
9 9 (H2 blank for spacer, could just use a different col.
27 175
100 100 460
it's the col H where i have my problem.
you'll have to run the code to check it out;
Let's say the number 460 was supposed to be 469, you'll have to do it to see my problem: click on the cell with 460 and watch what happens. it's too hard for me to explain here.
Thanks for any help.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Rows.Count <> 1 Or Target.Row = 1 Then Exit Sub
If Target.Offset(-1, 0) = Range("A1") Then Exit Sub
If Target.Column <> 8 Or Target.Offset(-1, 0).Value = "" Or Target = Range("H1") Then Exit Sub
With Range("B1:B" & Rows.Count)
Set b = .Find(Target.Offset(-1, 0).Value, LookAt:=xlWhole)
If Not b Is Nothing Then
b.Offset(0, -1) = Target.Offset(-1, 0)
Target.Offset(-1, 0) = ""
Else
'MsgBox "Code not found"
If Range("H3") = "" Then
Range("H3") = Target.Offset(-1, 0).Value
Range("H1") = ""
Else
Range("H" & Rows.Count).End(xlUp).Offset(1, 0) = Target.Offset(-1, 0).Value
Range("H1") = ""
End If
End If
End With
Target.Offset(-1, 0).Select
End Sub
I'm using the code to run an inventory I have a list of serial numbers of items i should have on hand
in col B. col A is blank for now. and i use Cell H1 as my entry point if you will. C-G have other stuff in them.
this is essentially what it looks like to begin with
34
76
89
56
02
69
101
75
200
369
I enter a number into H1, it searches col B if finds a match it places it into coresponding cell in Col A, if no match it places into H3, either way H1 resets and awaits the next entry. Subsequent non-matches just continue down col H.
A B H
3 (this is where i enter numbers)
9 9 (H2 blank for spacer, could just use a different col.
27 175
100 100 460
it's the col H where i have my problem.
you'll have to run the code to check it out;
Let's say the number 460 was supposed to be 469, you'll have to do it to see my problem: click on the cell with 460 and watch what happens. it's too hard for me to explain here.
Thanks for any help.