Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   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
  #2   Report Post  
Senior Member
 
Posts: 118
Default

Quote:
Originally Posted by jack_n_bub View Post
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
i am not able to understand your idea. do you mean to say that i must prefix your present code with that of the old one. or i should do it afresh? i see something like worksheet on the left pane and change on the right pane when i open the view code dialog. what should i do? click on change? and put your new code? however i did this -



i copied the original worksheet of mine Entryexit. then i went for view code. then i pasted your presentcode. p alt f11. saved the doc as macro enabled. when i checked,
it does not work as expected. it gives "syntex error" (visual basic) whenever i type something on row2.

Last edited by sumesh56 : November 5th 12 at 06:07 PM
  #3   Report Post  
Member
 
Location: Bangalore
Posts: 41
Default

Quote:
Originally Posted by sumesh56 View Post
i am not able to understand your idea. do you mean to say that i must prefix your present code with that of the old one. or i should do it afresh? i see something like worksheet on the left pane and change on the right pane when i open the view code dialog. what should i do? click on change? and put your new code? however i did this -



i copied the original worksheet of mine Entryexit. then i went for view code. then i pasted your presentcode. p alt f11. saved the doc as macro enabled. when i checked,
it does not work as expected. it gives "syntex error" (visual basic) whenever i type something on row2.
Hi,

Try these steps.

1) Go to the sheet where you will enter data.
2) on the sheet tab right click
3) Click on View Code
4) It will take you to the VBE window.
5) In the code window (right pane) paste my code.

If still unsure send me your file and I will send you the updated file.

Thanks,
Prashant
  #4   Report Post  
Senior Member
 
Posts: 118
Default

Quote:
Originally Posted by jack_n_bub View Post
Hi,

Try these steps.

1) Go to the sheet where you will enter data.
2) on the sheet tab right click
3) Click on View Code
4) It will take you to the VBE window.
5) In the code window (right pane) paste my code.

If still unsure send me your file and I will send you the updated file.

Thanks,
Prashant
thanks prashant.but i am sorry i am not able to find the result. now i am sending you the file again. pls check yourself whether it works or not. the code should work for the entire rows of the worksheet. pls direct me what should be the steps.
Attached Files
File Type: zip entry and exit FOR TEST.zip (6.3 KB, 39 views)
Reply
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 04:14 PM.

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"