Breaking Cell Formula into Multiple Pieces

TedSki

Board Regular
Joined
Apr 17, 2008
Messages
63
I have a cell that totals cash drops but I want to create a form to create the formula, place it into a cell and then display the pieces on the form.

The forumla is :

=100.00+5000.00+25000.00+10.05

Form will have value1 textbox and value2 textbox and value3 textbox etc.

When you click the save it will concatenate the "=" and value1 and "+" and value2 etc. and place the formula into the cell.

When the form first opens, I would like to break out each value that currently exists and display it in the correct textbox. The amounts can be any size - usually from about 25,000 to as low as 1.00.

Any ideas?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
This code should go in the userform that contains 4 text boxes (txtValue1 .....) and a Command Button named cmdSave

Code:
Private Sub cmdSave_Click()

    ActiveSheet.Range("A1").Formula = "=" & txtValue1 & "+" & txtValue2 & "+" & txtValue3 & "+" & txtValue4
    Me.Hide
    
End Sub

Private Sub UserForm_Activate()

    Dim varValues As Variant
    Dim sFormula As String
    
    sFormula = ActiveSheet.Range("A1").Formula
    varValues = Split(sFormula, "+")
    varValues(0) = Mid(varValues(0), 2, 1000)
    
    Me.txtValue1 = varValues(0)
    Me.txtValue2 = varValues(1)
    Me.txtValue3 = varValues(2)
    Me.txtValue4 = varValues(3)
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,571
Members
452,927
Latest member
whitfieldcraig

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