Stock Control Workbook

wtom0412

Board Regular
Joined
Jan 3, 2015
Messages
180
Office Version
  1. 365
Platform
  1. Windows
Good Afternoon All,

I am happy to report that as a direct result of all of the amazing help I get from you Guru's at MrExcel, I am needing to use the resource much less these days, however, this one has me stumped!!

I am creating a Stock Control Workbook.

As per the following image, I have a "Home" TAB, which gets user input.

Excel 2012
CDEFGH
10QuantityItemTransfer FromTransfer ToStock at ADFAStock at Amberley - Canteen
112Chef's Jacket - LADFAAmberley - Canteen

<tbody>
</tbody>
Home

I want to be able to have the stock list reflect the changes as per the user selection above.

Both the Location Names and the Item Names are dynamic in that they can change as locations and items get added or removed. By this I mean that if ADFA (B1) gets removed as a Location, Amberley - C17 will automatically move to Column B, and similarly, if "Black Cap" (A3) gets deleted as a stock item, "Blue and White Stripped Apron" will automatically go into line A3. So, I am guessing the references to Location and Item will need to use the Label as opposed to the fixed Column and Line numbers?

The next image is the "Stock List" TAB. As per the above example, I need VBA to reduce the quantity of "Chef's Jacket - L" from the the "ADFA" column by 2 (B9), and increase the the quantity in "Amberley - Canteen" by 2 (D9).

Excel 2012
ABCDEF
1Item and LocationADFAAmberley - C17Amberley - CanteenBorellaCanungara
2Charcoal Apron00000
3Black Cap00000
4Blue & White Striped Apron00000
5Blue & White Striped Hat00000
6Chef's Jacket - 2XL00000
7Chef's Jacket - 3XL33233
8Chef's Jacket - 4XL11111
9Chef's Jacket - L22222
10Chef's Jacket - M66666
11Chef's Jacket - S44444
12Chef's Jacket - XL11111
13Chef's Pants - 2XL11111
14Chef's Pants - 3XL00000
15Chef's Pants - 4XL11111
16Chef's Pants - L44444
17Chef's Pants - M55555
18Chef's Pants - S22222
19Chef's Pants - XL44444
20Chef's White Hat00000

<tbody>
</tbody>
Stock List

I also have an "Add Stock" section on the Home TAB, at the moment (until I get this current VBA sorted), it adds the stock to the "Lists" TAB. The following code adds the item to the stock list and also to a running stock count list.

Code:
Sub Add_New_Stock()


    Dim lastrow As Long


Application.ScreenUpdating = False


'Checks to see if Item already exists in Stock List
Dim FindString As String
Dim rng As Range
FindString = Range("C5").Value
If Trim(FindString) <> "" Then
    With Sheets("Lists").Range("A:A") 'searches all of column A
        Set rng = .Find(What:=FindString, _
                        After:=.Cells(.Cells.Count), _
                        LookIn:=xlValues, _
                        LookAt:=xlWhole, _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlNext, _
                        MatchCase:=False)
        If Not rng Is Nothing Then
            MsgBox "     Sorry, this code name already exists in the STOCK LIST." & vbNewLine & vbNewLine & "                             Please enter a unique Item"  'value  found
            Exit Sub
        Else
' If Item does not exist in stock list, Adds Item to the Running Stock Count, Adds the Item to the Stocl List, Sorts List Alphabetically and Deletes Duplicates


' This Adds the item to the Running Stock Count
Sheets("Home").Range("C5:D5").Copy
With Sheets("Lists").Range("G" & Rows.Count).End(xlUp).Offset(1)
    .PasteSpecial Paste:=xlPasteValues
End With


' This adds the item to the STOCK LIST
Sheets("Home").Range("S5:U5").Copy
With Sheets("Lists").Range("A" & Rows.Count).End(xlUp).Offset(1)
    .PasteSpecial Paste:=xlPasteValues
End With


' This copies the formula from the line above and pastes in; The formula =SUMIF(Tally,A7,Tally_Quantity) keeps a running tally of additions
Dim Col As Range
  For Each Col In Range("D:E").Columns
    With Cells(Rows.Count, Col.Column).End(xlUp)
      .Copy .Offset(1)
      .Value = .Value
    End With
  Next


' Sort_Product_Category Macro
    Sheets("Lists").Select
    Columns("A:E").Select
    ActiveWorkbook.Worksheets("Lists").Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Lists").Sort.SortFields.Add Key:=Range("A2:A500") _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Lists").Sort
        .SetRange Range("A2:A500")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    
    ' Remove_Duplicates
    Sheets("Lists").Select
    Columns("A:E").Select
    ActiveSheet.Range("$A$1:$E$5000").RemoveDuplicates Columns:=1, Header:=xlYes




Worksheets("Home").Activate


Application.CutCopyMode = False
Application.ScreenUpdating = True


End If
    End With
End If


 
End Sub



I really hope someone can help me, I am getting a bit stir crazy (been trying to figure this out for two days!!). I am sure I have left a few things out in my explanation, but I hope you understand what I am trying to achieve.

Thank you in advance.

WT
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,215,559
Messages
6,125,517
Members
449,236
Latest member
Afua

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