remained balance for ID based on textbox on userform

Maklil

Board Regular
Joined
Jun 23, 2022
Messages
175
Office Version
  1. 2019
Platform
  1. Windows
Hello
I want giving the remained QTY by calculation across sheet in textbox2 based on writing in textbox1 (ID)
, but before calculation should merge QTY for duplicates ID for each sheet separately .
the calculation QTY for column D across sheet should be SH2-DFG+HJK-SH
for instance when merge for each sheet take SDFR-1000 , then will be 900-370+10-40=500 as in picture1
some elements are existed in sheet but are
not existed in the others sheet like SDFR-1004,SDFR-1002 as in pictures .





Microsoft Excel (3)‬.xlsx
ABCD
1ITEMDATEIDQTY
2125/05/2023SDFR-1000600
3226/05/2023SDFR-1001200
4327/05/2023SDFR-VBNBN-9150
5428/05/2023SDFR-1000300
6529/05/2023SDFR-VBNBN-9150
SH2




Microsoft Excel ‫(3)‬.xlsx
ABCD
1ITEMDATEIDQTY
2125/06/2023SDFR-1000120
3226/06/2023SDFR-1000100
4327/06/2023SDFR-100050
5428/06/2023SDFR-1000100
6529/06/2023SDFR-VBNBN-9150
DFG





Microsoft Excel ‫(3)‬.xlsx
ABCD
1ITEMDATEIDQTY
2125/06/2023SDFR-10005
3226/06/2023SDFR-10005
4327/06/2023SDFR-10046
HJK



Microsoft Excel ‫(3)‬.xlsx
ABCD
1ITEMDATEIDQTY
2125/06/2023SDFR-100020
3226/06/2023SDFR-100020
4326/05/2023SDFR-1001200
5427/05/2023SDFR-1002201
SH

MK1.JPG


MK2.JPG

MK3.JPG

I hope the pictures help
thanks
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi.
I assumed that there will be a command button on the userform.

VBA Code:
Private Sub CommandButton1_Click()
 Dim ws As Worksheet, LR As Long, qtyP As Double, qtyT As Double
  If TextBox1.Text <> "" Then
   For Each ws In Worksheets(Array("SH2", "DFG", "HJK", "SH"))
    LR = ws.Cells(Rows.Count, 3).End(3).Row
    qtyP = WorksheetFunction.SumIf(ws.Range("C2:C" & LR), TextBox1.Text, ws.Range("D2:D" & LR))
    If ws.Name = "DFG" Or ws.Name = "SH" Then qtyT = qtyT - qtyP Else qtyT = qtyT + qtyP
   Next ws
   TextBox2.Text = qtyT
  End If
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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