LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Member
 
Location: Bangalore
Posts: 41
Thumbs up

Quote:
Originally Posted by jack_n_bub View Post
Hi,

Attached is the updated file and hopefully contains everything you were looking for.

It does the following.
Wouldn't give Error Message if any of the cells (in Entry or Exit boxes) is left empty.
Would give error if only all of the cells are filled in the two sections and their total don't match.
Moreover, it undoes your last action to resume to original state.

Let me know if this works for you.

Thanks,
Prahsant
Hi,

Apologies for a delay in response. I wasn't feeling well and couldn't see your message.

I thought you are always going to use only 1 row. Here is a small edit that you need to make in the code.

replace the worksheet_change code in the thisworkbook object with the following code.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim CheckRng As Range
Dim EntryRng As Range
Dim ExitRng As Range
Set EntryRng = Range(Cells(Target.Row, 1), Cells(Target.Row, 4))
Set ExitRng = Range(Cells(Target.Row, 7), Cells(Target.Row, 10))
Set CheckRng = Application.Union(EntryRng, ExitRng)

If Not Application.Intersect(Target, CheckRng) Is Nothing Then
If Application.WorksheetFunction.CountBlank(EntryRng) = 0 And Application.WorksheetFunction.CountBlank(ExitRng) = 0 Then
If Application.WorksheetFunction.Sum(EntryRng) < Application.WorksheetFunction.Sum(ExitRng) Then
MsgBox "The Entry Total is not matching with Exit Total", vbCritical, "Error"
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Exit Sub
End If
End If
End If
End Sub

Hope this helps.
Prashant
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
conditional formatting for wrongly entered 9 digit numbers andreashermle Excel Programming 13 November 6th 09 02:11 PM
Using a Macro in Excel 2004 to move entered data from one sheet toanother and space between rows when next data is entered? [email protected] Excel Programming 1 June 4th 08 05:08 PM
List Box - Option If wrongly selected Rob Excel Programming 2 August 24th 05 02:25 PM
Time displaying wrongly Denise Robinson Excel Discussion (Misc queries) 3 August 9th 05 02:30 PM
sorry i put wrongly for padded leading 0 tango Excel Programming 1 November 12th 04 12:22 AM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"