Excel - Edit Data

Dinngz

New Member
Joined
Jan 28, 2025
Messages
11
Office Version
  1. Prefer Not To Say
Platform
  1. Windows
Hi All,

Im looking for advice on how i can implement an idea i'm struggling to.

I have an excel workbook where i am storing stock information. This includes Name, Location and Stock Amount, as seen below

Using data validation and then the VLOOKUP function i have pulled in stock information into a form.

I want to essential recreate the form, where the data is pulled in, but instead of number of stock, it will be Book Out Stock, so the user inputs x amount used. This will then edit the data sheet to the now remaining number.

Is anyone able to offer advise on how to achieve this?

Stock List.xlsm
ABCDEFGHIJK
9
10
11Inventory Stock Check
12
13Select Item:
14
15Stock LocationNo. Of Stock
16RACK1, E060
17
18
19
20
21
22
23Book Stock Out
24
25
26
27
28
29
30
31
32
33
Sheet1
Cell Formulas
RangeFormula
D16D16=XLOOKUP(D13, Inventory!$A$2:$A$1234, Inventory!$B$2:B$1234)
G16G16=XLOOKUP(D16, Inventory!$B$2:$B$1234, Inventory!$C$2:C$1234)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G16:H18Cell Value>=5textNO
G16:H18Cell Valuebetween 0 and 2textNO
G16:H18Cell Valuebetween 3 and 4textNO
Cells with Data Validation
CellAllowCriteria
D13:H13List=Inventory!$A$2:$A$1048576


Inventory Page

Stock List.xlsm
ABC
1ItemLocationAmount
2400v 3 Pole Circuit BreakerRACK 1, A0114
3Motor Contact BlockRACK 1, A022
4230v - 415v Single Pole BreakerRACK 1, A035
53 Pole 9 - 14 amp BreakerRACK 1, A041
6Contact AuxillariesRACK 1, A056
7110v Commando Panel Socket - 2P+E (Yellow)RACK 1, A061
8110v Commando Panel Plug - 2P+E (Yellow)RACK 1, A070
916a Commando Socket 3P+E (Red)RACK1, B013
1016a Commando Plug 3P+E (Red)RACK1, B026
1116a Commando Socket 2P+E (Blue)RACK1, B032
1216a Commando Plug 2P+E (Blue)RACK1, B042
1316a Commando Joining Plug Female 3P+ERACK1, B054
Inventory


Much apprecaited
 
Currently when you select a value in D13, the Stock Location and No. Of Stock are populated in D16 and G16 respectively.
instead of number of stock, it will be Book Out Stock, so the user inputs x amount used. This will then edit the data sheet to the now remaining number.
I'm not sure what you mean by this. Do you want to manually enter the x amount used in C23 and subtract that number from the amount in column C of the Inventory sheet? Please clarify in detail referring to specific cells and sheets using a few examples from your data.
 
Upvote 0
Currently when you select a value in D13, the Stock Location and No. Of Stock are populated in D16 and G16 respectively.

I'm not sure what you mean by this. Do you want to manually enter the x amount used in C23 and subtract that number from the amount in column C of the Inventory sheet? Please clarify in detail referring to specific cells and sheets using a few examples from your data.
I am wanting to create another section below, that allows me to then book stock out. This area would include another drop down box to select the item required from the inventory sheet.

The user would then input (for arguments sake) 2 in cell C24. That would then deduct the value from the row in the inventory sheet that contains the item. So if there was 4 items in stock for x item, it would alter the value by -2 to now show 2 left.

I hope this is better explain :)
 
Upvote 0
Click here to download your file. When you make a selection in D13, cells D16 and G16 will be automatically populated. You don't need the formulas anymore. Next make a selection in D25 and then enter a quantity in D27 and press the ENTER key. Cell G27 will be automatically populated and the amount in the Inventory sheet will be automatically adjusted. The macro runs automatically when make a selection in D13, D25 and enter a value in D27. The code is located in the code module for Sheet1. To view the code, right click the tab name for Sheet1 and click 'View Code'. Close the code window to return to your sheet. This is the code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("D13,D25,D27")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim item As Range, desWS As Worksheet
    Set desWS = Sheets("Inventory")
    Select Case Target.Address(0, 0)
        Case "D13"
            Set item = desWS.Range("A:A").Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("D16") = item.Offset(, 1)
            Range("G16") = item.Offset(, 2)
        Case "D25"
            Range("D27").ClearContents
            Range("G27").ClearContents
        Case "D27"
            Set item = desWS.Range("A:A").Find(Range("D25").Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("G27") = item.Offset(, 2) - Target.Value
            item.Offset(, 2) = item.Offset(, 2) - Target.Value
    End Select
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Click here to download your file. When you make a selection in D13, cells D16 and G16 will be automatically populated. You don't need the formulas anymore. Next make a selection in D25 and then enter a quantity in D27 and press the ENTER key. Cell G27 will be automatically populated and the amount in the Inventory sheet will be automatically adjusted. The macro runs automatically when make a selection in D13, D25 and enter a value in D27. The code is located in the code module for Sheet1. To view the code, right click the tab name for Sheet1 and click 'View Code'. Close the code window to return to your sheet. This is the code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("D13,D25,D27")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim item As Range, desWS As Worksheet
    Set desWS = Sheets("Inventory")
    Select Case Target.Address(0, 0)
        Case "D13"
            Set item = desWS.Range("A:A").Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("D16") = item.Offset(, 1)
            Range("G16") = item.Offset(, 2)
        Case "D25"
            Range("D27").ClearContents
            Range("G27").ClearContents
        Case "D27"
            Set item = desWS.Range("A:A").Find(Range("D25").Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("G27") = item.Offset(, 2) - Target.Value
            item.Offset(, 2) = item.Offset(, 2) - Target.Value
    End Select
    Application.ScreenUpdating = True
End Sub

Hats off to you :)

Very much appreciated and exactly what I was after. Thank you ever so much :)
 
Upvote 0
Click here to download your file. When you make a selection in D13, cells D16 and G16 will be automatically populated. You don't need the formulas anymore. Next make a selection in D25 and then enter a quantity in D27 and press the ENTER key. Cell G27 will be automatically populated and the amount in the Inventory sheet will be automatically adjusted. The macro runs automatically when make a selection in D13, D25 and enter a value in D27. The code is located in the code module for Sheet1. To view the code, right click the tab name for Sheet1 and click 'View Code'. Close the code window to return to your sheet. This is the code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("D13,D25,D27")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim item As Range, desWS As Worksheet
    Set desWS = Sheets("Inventory")
    Select Case Target.Address(0, 0)
        Case "D13"
            Set item = desWS.Range("A:A").Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("D16") = item.Offset(, 1)
            Range("G16") = item.Offset(, 2)
        Case "D25"
            Range("D27").ClearContents
            Range("G27").ClearContents
        Case "D27"
            Set item = desWS.Range("A:A").Find(Range("D25").Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("G27") = item.Offset(, 2) - Target.Value
            item.Offset(, 2) = item.Offset(, 2) - Target.Value
    End Select
    Application.ScreenUpdating = True
End Sub
Just on top of this... I've had an extra idea. On booking out the item, would it be possible to save what part has been booked out with number and a date time stamp to a separate page for historical records?
 
Upvote 0
Create another sheet and name it "Historical". In that sheet enter the headings "Item" in A1, "Quantity" in B1 and "Date" in C1. Replace the current macro with this one:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("D13,D25,D27")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Dim item As Range, desWS As Worksheet
    Set desWS = Sheets("Inventory")
    Select Case Target.Address(0, 0)
        Case "D13"
            Set item = desWS.Range("A:A").Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("D16") = item.Offset(, 1)
            Range("G16") = item.Offset(, 2)
        Case "D25"
            Range("D27").ClearContents
            Range("G27").ClearContents
        Case "D27"
            Set item = desWS.Range("A:A").Find(Range("D25").Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("G27") = item.Offset(, 2) - Target.Value
            item.Offset(, 2) = item.Offset(, 2) - Target.Value
            With Sheets("Historical")
                .Cells(.Rows.Count, "A").End(xlUp).Offset(1).Resize(, 3).Value = Array(item, Target.Value, Now())
            End With
    End Select
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Create another sheet and name it "Historical". In that sheet enter the headings "Item" in A1, "Quantity" in B1 and "Date" in C1. Replace the current macro with this one:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("D13,D25,D27")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Dim item As Range, desWS As Worksheet
    Set desWS = Sheets("Inventory")
    Select Case Target.Address(0, 0)
        Case "D13"
            Set item = desWS.Range("A:A").Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("D16") = item.Offset(, 1)
            Range("G16") = item.Offset(, 2)
        Case "D25"
            Range("D27").ClearContents
            Range("G27").ClearContents
        Case "D27"
            Set item = desWS.Range("A:A").Find(Range("D25").Value, LookIn:=xlValues, lookat:=xlWhole)
            Range("G27") = item.Offset(, 2) - Target.Value
            item.Offset(, 2) = item.Offset(, 2) - Target.Value
            With Sheets("Historical")
                .Cells(.Rows.Count, "A").End(xlUp).Offset(1).Resize(, 3).Value = Array(item, Target.Value, Now())
            End With
    End Select
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub
Excellent, Much appreciated mumps :)

If i wanted to add more cells at a later date that would pull to the historical sheet, how would i input this code? Would i copy the case "D27" and adjust for the cell i want?
 
Upvote 0
You are very welcome. :)
You would add the code to case "D27". The code would depend on which data you want to add and the location of its destination. Also, when replying to a post, use the "Reply" button rather than the "+Quote" button to keep things simple unless there is a specific reason to add the quote.
 
Upvote 0
Im planning to add a simple text box, so it would pull the text typed and insert it into the historical data with the part booked out. It would essentially be a description to say why it was booked out
 
Upvote 0

Forum statistics

Threads
1,226,771
Messages
6,192,918
Members
453,766
Latest member
Gskier

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