TextBox Values with SUM & SUMIF

Denny57

Board Regular
Joined
Nov 23, 2015
Messages
185
Office Version
  1. 365
Platform
  1. Windows
I have tried a variety of lines of code to convert a textBox value so it can be read by the SUMIF function in a WS. but without success

I have a cashflow sheet into which currency formatted transactions are added via a userform.

VBA Code:
Private Sub txtTransactionAmountDebit_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtTransactionAmountDebit.Value = Format(txtTransactionAmountDebit.Value, "Currency")
End Sub

Transactions are added to the ws with a "Pending" indicator which is subsequently altered to "Paid". I am using SUMIF to total the value of all "Pending" transactions and then adjust the current balance with this amount. The function works fine when I enter amounts directly into the worksheet, but these are not recognised if they are entered from the UserForm.

I appreciate that this is perhaps because by nature the value in a textbox is "Text" format but i have managed to get some functions to work with currency values from a textbox in other worksheets.

Is there some other method (I have tried using cDbl) to format the textbox values so thay can be recognised by SUM and SUMIF functions in the Worksheet
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
VBA Code:
Range("A" & Rows.Count).End(xlUp).Offset(1, 0).NumberFormat = "$#,##0.00"
Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = TextBox1.Value

Try this code and btw what's the format of the cell once you enter the value.
 

Attachments

  • 1673696432857.png
    1673696432857.png
    27.9 KB · Views: 5
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,019
Members
448,938
Latest member
Aaliya13

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