easiest way to do this?

viper

Active Member
Joined
Feb 15, 2002
Messages
382
I am working on a spreadsheet to enter purchases. I will have probably have 25-30 cells with a case quanity and a total dollar amount for the purchase. To prevent errors in entering I want to either have a message box notify the user of the incorrect entry and change the cell color or display the message box of the error and then clear the cells contents. To do the above I will need for each cell(say column b, rows 10 to 40) to divide its entry($100.00) by column c, rows 10 to 40) their entry(4). So I will need for b10/c10,b11/c11 and so on. The error I am looking for will be a difference of 10% in the case cost. I will probably have to have a column for the start up case cost so that each time the user makes an entry it will check his/her entry against the case price. So i will have row b as the qty., c as the dollar amount, and say e as the initial cost/case. Will I need to write a conditional format code for each cell or use the worksheet calculate event?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Viper, I would use conditional formatting for this. You will get in to trouble if you try and use the worksheet's code. For example, if I use the worksheet's code to notify the user that there is an error, they will get this notification as soon as they enter something in column B or column C before they get a chance to enter something in the other column. Of course, if you can ensure that the users will enter in one column FIRST, then you code use code. Something like (assumes they enter column B first):
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column = 3 Then
    If Target.Offset(0, 2).Value > 0.1 Then
        MsgBox ("Incorrect amounts entered")
    End If
End If
End Sub

Hope this explanation is clear.
:)
 
Upvote 0
Thanks Barrie,

I'll try it both ways and see which I like better. If I try the worksheet code I'll set it up so the second column won't except an entry until the first column has an entry.
 
Upvote 0

Forum statistics

Threads
1,214,535
Messages
6,120,090
Members
448,944
Latest member
sharmarick

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