Inventory Control help....

chefdt

Board Regular
Joined
Jul 1, 2008
Messages
163
[h=2][/h] <ins style="display:inline-table;border:none;height:60px;margin:0;padding:0;position:relative;visibility:visible;width:234px;background-color:transparent"><ins id="aswift_0_anchor" style="display:block;border:none;height:60px;margin:0;padding:0;position:relative;visibility:visible;width:234px;background-color:transparent"></ins></ins>
I have a WORKBOOK named "Inventory". It consists of several WORKSHEETS that divide my food inventory into categories such as "MEAT", "DAIRY PRODUCTS", etc.

I recorded a macro that will import my inventory from an online ordering system, dump it to a WORKSHEET named "IMPORT" and normalize the data.

I want to create a macro that looks through the import data and parses it into the appropriate WORKSHEET.

Column "I" of the "IMPORT" sheet contains the name of the WORKSHEET that the data needs to be copied to.

The other worksheets will already have data in them, starting at "A8". As each item is copied to the appropriate sheet, I want to verify if the item already exists on the sheet and do one of two options.....A) If it exists, copy only "H" which is the case cost, and flag by color or bold text if the new price is different from the current B) If it doesn't exist, add the entire row of data to the bottom row of data in the appropriate sheet.

Here is a sample of "IMPORT" and "DAIRY"

Dairy Products

ABCDEFGHIJKLM
1Todays Date:10/31/2013Total:
2Date of Last Inventory:3/12/2010$ -
3Days Since Last Inventory:1329
4Last Person to Inventory:
5
6
7SUPCItem DescriptionBrandCountPackage SizeMfg #Re-order CountCase CostCaseEachUnit CostUnits in StockTotal $
88965881BUTTERMILK 1% LOW FATWHLFARM9.5 GAL$ 19.05$ 2.12$ -
96697890CHEESE AMER YEL 160 SLIBBRLCLS45 LB$ 37.68$ 9.42$ -
102404135CHEESE CHDR YEL MILKD SHRD FTHRCASASOL45 LB$ 45.80$ 11.45$ -
117234958CHEESE CUBE CHDR/COJCK/PEP JCKBBRLIMP35 #$ 48.00$ 16.00$ -
124791386CHEESE CUBE HAVARTI/GOUDA/MUFNSCHRBER35 LB$ 46.74$ 15.58$ -

<tbody>
</tbody>



Import

ABCDEFGHI
1SUPCDescBrandPackSizeMfr #ParCase $Cat
2DAIRY PRODUCTS
30671677CHEESE BLUE CRUMBLESSYS IMP25 LB10000847$ 12.59Dairy Products
45469259CHEESE BRIE DOMSTC 1 KGBBRLIMP22.2 LB10007830$ 17.28Dairy Products
52406189CHEESE CHDR JACK SHRD FCYCASASOL45 LB10000253$ 47.78Dairy Products
62599793CHEESE CHDR MILD YEL PRNTBBRLIMP110 LB10000253$ 23.70Dairy Products
76159263CHEESE CHDR SHRP PRNT YELBBRLIMP110 LB10000253$ 27.32Dairy Products
82357598CHEESE CHDR SMKDTILAMOK62 LB10007703$ 61.70Dairy Products
92357580CHEESE CHDR XSHRP WHITETILAMOK25 LB10007703$ 53.95Dairy Products
102220143CHEESE FETA CRUMBLE DOMSYS IMP25 LB10000847$ 36.21Dairy Products

<tbody>
</tbody>


Any help appreciated!​
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Can you list all of the categories that you will use?

Dairy Products
Meat
Seafood
Poultry
Canned And Dry
Frozen
Paper & Disp
Supp & Equip
Produce
Dispenser Bevrg
Chemical/Janitrl

One small problem also is that my worksheets are named this way, as that is how they come from the online system. I have to go in and manually change all of the "Chemical/Janitrl" to "Chemical" because I can't use the "/" character in the sheet name. I'm sure I could write the macro to filter and rename as it came into the import sheet, but if you have an easier way......Thanks
 
Upvote 0
Another problem I seem to have is how to keep the destination formatting. Don't know how to do that. I always have to go back in and reformat after copying.
 
Upvote 0
Ok try this, but please save your work first:

Code:
Sub InventoryUpdate()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim LastRow As Long
Dim i As Long
Dim CatCol As Long, SUPCcol As Long, CaseCol As Long
Dim SUPCMatch As Range


With Application
    .ScreenUpdating = False
    .DisplayAlerts = False
End With


On Error Resume Next
Set ws1 = Sheets("Import")
On Error GoTo 0
If ws1 Is Nothing Then MsgBox "There is no Import Sheet": Exit Sub
ws1.Select


CatCol = ws1.Cells(1, 1).EntireRow.Find(What:="Cat", LookIn:=xlValues, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column
SUPCcol = ws1.Cells(1, 1).EntireRow.Find(What:="SUPC", LookIn:=xlValues, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column
CaseCol = ws1.Cells(1, 1).EntireRow.Find(What:="Case $", LookIn:=xlValues, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column
LastRow = ws1.Cells(ws1.Rows.Count, CatCol).End(xlUp).Row


For i = 2 To LastRow
    If ws1.Cells(i, CatCol).Value <> "" Then
        On Error Resume Next
        Set ws2 = Sheets(Replace(ws1.Cells(i, CatCol).Value, "/", ""))
        On Error GoTo 0
            If Not ws2 Is Nothing Then
                Set SUPCMatch = ws2.Columns(1).Find(What:=ws1.Cells(i, SUPCcol).Value, LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
                    If SUPCMatch Is Nothing Then
                        ws1.Range(Cells(i, 1), Cells(i, 8)).Copy
                        ws2.Range("A" & ws2.Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll
                    Else
                        If ws1.Cells(i, CaseCol).Value <> SUPCMatch.Offset(0, 7).Value Then
                            With SUPCMatch.Offset(0, 7).Interior
                                .Pattern = xlSolid
                                .ThemeColor = xlThemeColorLight1
                                .PatternColorIndex = xlAutomatic
                            End With
                            With SUPCMatch.Offset(0, 7).Font
                                .ThemeColor = xlThemeColorDark1
                                .Bold = True
                            End With
                        End If
                    End If
            End If
    End If
ws1.Select
Next i
With Application
    .ScreenUpdating = True
    .DisplayAlerts = True
End With
MsgBox "Import Complete"
End Sub

If there are any price differences it will change the background to black, text too white and bold so that you can't miss it :)

BTW you don't need to remove the "/" from the Category column, this will do that also.
 
Upvote 0
Ok try this, but please save your work first:

Code:
Sub InventoryUpdate()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim LastRow As Long
Dim i As Long
Dim CatCol As Long, SUPCcol As Long, CaseCol As Long
Dim SUPCMatch As Range


With Application
    .ScreenUpdating = False
    .DisplayAlerts = False
End With


On Error Resume Next
Set ws1 = Sheets("Import")
On Error GoTo 0
If ws1 Is Nothing Then MsgBox "There is no Import Sheet": Exit Sub
ws1.Select


CatCol = ws1.Cells(1, 1).EntireRow.Find(What:="Cat", LookIn:=xlValues, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column
SUPCcol = ws1.Cells(1, 1).EntireRow.Find(What:="SUPC", LookIn:=xlValues, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column
CaseCol = ws1.Cells(1, 1).EntireRow.Find(What:="Case $", LookIn:=xlValues, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column
LastRow = ws1.Cells(ws1.Rows.Count, CatCol).End(xlUp).Row


For i = 2 To LastRow
    If ws1.Cells(i, CatCol).Value <> "" Then
        On Error Resume Next
        Set ws2 = Sheets(Replace(ws1.Cells(i, CatCol).Value, "/", ""))
        On Error GoTo 0
            If Not ws2 Is Nothing Then
                Set SUPCMatch = ws2.Columns(1).Find(What:=ws1.Cells(i, SUPCcol).Value, LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
                    If SUPCMatch Is Nothing Then
                        ws1.Range(Cells(i, 1), Cells(i, 8)).Copy
                        ws2.Range("A" & ws2.Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll
                    Else
                        If ws1.Cells(i, CaseCol).Value <> SUPCMatch.Offset(0, 7).Value Then
                            With SUPCMatch.Offset(0, 7).Interior
                                .Pattern = xlSolid
                                .ThemeColor = xlThemeColorLight1
                                .PatternColorIndex = xlAutomatic
                            End With
                            With SUPCMatch.Offset(0, 7).Font
                                .ThemeColor = xlThemeColorDark1
                                .Bold = True
                            End With
                        End If
                    End If
            End If
    End If
ws1.Select
Next i
With Application
    .ScreenUpdating = True
    .DisplayAlerts = True
End With
MsgBox "Import Complete"
End Sub

If there are any price differences it will change the background to black, text too white and bold so that you can't miss it :)

BTW you don't need to remove the "/" from the Category column, this will do that also.



Looks like it's almost working...fantastic. Just a couple of things. The items come into the correct sheets, but keep their original formatting, and not that of the destination sheet. I also have a formula in Column K of the destination Category sheets...=IF(D10<="",IF(H10<>"",H10/D10,"")) I need to have that pasted in for each new item.

The formatting for existing items changed to WHITE on a GREY background....probably not what you had in mind.

Thanks.
 
Upvote 0
Hey....Sorry to bother. I figured out the formatting and formula issues, but the code to highlight the new price produces the following result.

Produce


ABCDEFGHIJK
1021740885SALAD TABBOULEH WHEATBISHOP43 LB10007539
$ 37.89

$ 9.47
1031350024SAMPLE COOLERPACKER1CS

$ 37.89

$ 37.89
1047449309SAMPLE COOLER #2SAMPLE1CS10007258
$ 37.89

$ 37.89

<colgroup> <col style="WIDTH: 30px; FONT-WEIGHT: bold"> <col style="WIDTH: 56px"> <col style="WIDTH: 195px"> <col style="WIDTH: 62px"> <col style="WIDTH: 36px"> <col style="WIDTH: 71px"> <col style="WIDTH: 74px"> <col style="WIDTH: 81px"> <col style="WIDTH: 55px"> <col style="WIDTH: 30px"> <col style="WIDTH: 30px"> <col style="WIDTH: 55px"></colgroup> <tbody>
</tbody>

Prices changed in items of ROW 103 and 104. It kept the old price, and did not update, also only turned the background of the WHITE cell to black.

How about a macro to clear the formatting (highlighted prices) back to original.
 
Upvote 0
Hey....Sorry to bother. I figured out the formatting and formula issues, but the code to highlight the new price produces the following result.

Produce

ABCDEFGHIJK
1021740885SALAD TABBOULEH WHEATBISHOP43 LB10007539$ 37.89$ 9.47
1031350024SAMPLE COOLERPACKER1CS$ 37.89$ 37.89
1047449309SAMPLE COOLER #2SAMPLE1CS10007258$ 37.89$ 37.89

<tbody>
</tbody>

Prices changed in items of ROW 103 and 104. It kept the old price, and did not update, also only turned the background of the WHITE cell to black.

How about a macro to clear the formatting (highlighted prices) back to original.

Can you post the code you are using now that you have made amendments? And what version of excel are you using?
 
Upvote 0
Can you post the code you are using now that you have made amendments? And what version of excel are you using?

I was able to change the formatting on my own...victory for me!

I can't figure the code to paste the updated price into WS2 however. I keep getting errors!!

Here is what I tried................

If SUPCMatch Is Nothing Then
ws1.Range(Cells(i, 1), Cells(i, 8)).Copy
ws2.Range("A" & ws2.Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll

Else
If ws1.Cells(i, CaseCol).Value <> SUPCMatch.Offset(0, 7).Value Then
ws1.Range(Cells(i, 7), Cells(i, 7)).Copy
ws2.Range(SUPCMatch(0, 7)).PasteSpecial xlPasteValues

With SUPCMatch.Offset(0, 7).Interior
.Pattern = xlSolid
.ThemeColor = xlThemeColorLight1
.PatternColorIndex = xlAutomatic
End With
With SUPCMatch.Offset(0, 7).Font
.ThemeColor = xlThemeColorDark1
.Bold = True
End With
End If
End If

Using Excel 2010.

Thanks!
 
Upvote 0
Ahh I missed that out.

Rich (BB code):
If SUPCMatch Is Nothing Then
                        ws1.Range(Cells(i, 1), Cells(i, 8)).Copy
                        ws2.Range("A" & ws2.Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteAll
                    Else
                        If ws1.Cells(i, CaseCol).Value <> SUPCMatch.Offset(0, 7).Value Then
                            With SUPCMatch.Offset(0, 7).Interior
                                .Pattern = xlSolid
                                .ThemeColor = xlThemeColorLight1
                                .PatternColorIndex = xlAutomatic
                            End With
                            With SUPCMatch.Offset(0, 7).Font
                                .ThemeColor = xlThemeColorDark1
                                .Bold = True
                            End With
.Value = ws1.Cells(i, CaseCol).Value
                        End If
                    End If

add that line.
 
Upvote 0

Forum statistics

Threads
1,215,947
Messages
6,127,867
Members
449,410
Latest member
adunn_23

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