Help with an inventory Macro

Rave

New Member
Joined
Sep 11, 2006
Messages
38
Ok folks, I'm stealing bits and pieces of code examples that I'm find on the internet as well as the help tool in Visual Basic to try and make this work. What I'm trying to do is create a macro that will help me with the inventory at my store. I'm using Excel to do so. The following code is what I have so far.

Sub Inventory()
Cells.Find(What:=InputBox("Please Scan ID Number", "Inventory"), _
After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate

Worksheets("Sheet1").Activate
With ActiveCell
.Interior.ColorIndex = 6
End With

End Sub


This code will currently search the spreadsheet for the cell matching the product the user is scanning and fill the cell yellow. This part is working correctly. From here I need the macro to automatically restart so the user can scan the next piece of merchandise. I would also like a warning box to pop up if the macro is not able to find a match saying "No Match Found" Like I said, I am not a programmer at all and am just looking for help on this. Any help would be greatly appreciated!

Thanks,

-Mike
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Welcome to the Board!

How's this for a start:

<font face=Tahoma><SPAN style="color:#00007F">Sub</SPAN> Inventory()
        <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> UhOhh
        Sheets("Sheet1").Cells.Find(What:=InputBox("Please Scan ID Number", "Inventory"), _
            After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
            SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            <SPAN style="color:#00007F">False</SPAN>).Interior.ColorIndex = 6
        Inventory
        
UhOhh:
    MsgBox "Search Item Not Found"
    <SPAN style="color:#00007F">End</SPAN>
    
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

Hope that helps,

Smitty
 
Upvote 0
you can try also this one;
Code:
Sub Inventory()
start:
With ActiveSheet.UsedRange
Set c = .Find(InputBox("Please Scan ID Number", "Inventory"), , , xlWhole)
If Not c Is Nothing Then
c.Interior.ColorIndex = 6
Else
MsgBox "ID Number not Found", vbInformation + vbOKOnly, "No Record found!"
End If
End With
If MsgBox("Scan next item", vbInformation + vbYesNo, "Next") = vbNo Then
GoTo end_session:
Else
GoTo start:
End If
end_session:
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,153
Messages
6,164,250
Members
451,882
Latest member
Bigtop

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top