![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
I am using a userform to input accounts and amounts into a ledger. How can I make sure that individual account amounts match the invoice total and if not let the user know so that the user can check the input before the userform posts to the ledger?
I've tried inserting a separate module and used this code: Sub CheckData() If Textbox1.Value = Textbox2.Value + Textbox3.Value + Textbox3.Value + Textbox4.Value Then Exit Sub Else MsgBox ("Please check your input, account s and invoice don't match!") End IF End Sub I called this module before the posting of the information but it didn't work. It posted it anyway not matter if the totals matched or not. Thanks,
__________________
I appreciate the help from everyone at Mr. Excel. viper |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
|
I think that having the function check your invoice amounts and then returning a value would be better. Something like this:
Code:
Function CheckData() as Boolean CheckData = (Textbox1.Value = Textbox2.Value + Textbox3.Value + Textbox3.Value + Textbox4.Value) End Function In the procedure where you will be sending the data to the sheet, put something like this: If Not CheckData Then MsgBox ("Please check your input, account s and invoice don't match!") Exit Sub End If ________________ Hope this helps, Russell p.s. - I just noticed that you are adding TextBox3 twice in your example...which I copied for my example. [ This Message was edited by: Russell Hauf on 2002-03-28 12:59 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|