distrubuting amounts from textbox on user form to column inside sheet

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
465
Office Version
  1. 2019
Hi guys,
I search for procedure to distributing amounts from textbox1 on userform to column D inside the sheet .
aq Microsoft Excel .xlsx
ABCDE
4ITEMBRANDQTYUNIT PRICETOTAL
51BS 1200R20 G580 JAP5.001,880.009,400.00
62BS 1200R20 G580 THI10.002,200.0022,000.00
73BS 1400R20 VSJ JAP20.004,300.0086,000.00
80.00
90.00
100.00
110.00
12TOTAL35.00117,400.00
we
Cell Formulas
RangeFormula
C12,E12C12=SUM(C5:C11)
E5:E11E5=C5*D5


when write amount in textbox1 =10,000.00 then should divide on last value in column C like this 10,000.00/35.00=285.7143
and the value 285.7143 should add to column D for unit price for each item like this
285.7143+1,880.00=2,165.71
285.7143 +2,200.00=2,485.71
285.7143+4,300.00=4,585.71

final result
aq Microsoft Excel .xlsx
ABCDE
4ITEMBRANDQTYUNIT PRICETOTAL
51BS 1200R20 G580 JAP5.002,165.7110,828.55
62BS 1200R20 G580 THI10.002,485.7124,857.10
73BS 1400R20 VSJ JAP20.004,585.7191,714.20
80.00
90.00
100.00
110.00
12TOTAL35.00127,399.85
we
Cell Formulas
RangeFormula
C12,E12C12=SUM(C5:C11)
E5:E11E5=C5*D5
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try this:

VBA Code:
Private Sub CommandButton1_Click()
  Dim distamount As Double
  Dim i As Long
  
  With TextBox1
    If .Value = "" Or Not IsNumeric(.Value) Then
      MsgBox "Enter value"
      .SetFocus
      Exit Sub
    End If
    distamount = .Value / Range("C" & Rows.Count).End(3).Value
  End With
  
  i = 5
  Do While Range("D" & i).Value <> ""
    Range("D" & i).Value = Range("d" & i).Value + distamount
    i = i + 1
  Loop
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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