Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you very much.
It worked. The only minor thing I did is change as snippet to the following: (Target.Value = 1 Or Target.Value = 2) And _ (Target.Offset(, -1).Value < "" _ And Target.Offset(, -1).Value = 0) because it was giving the alert when the cell to the left was blank before this change. Thanks again. Wissam "Mike H" wrote: Hi, I think i've understood the question , try this. Right click your sheet tab, view code and paste this code in Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub If Not Intersect(Target, Range("C1:M41")) Is Nothing Then If Target.Value = 1 Or Target.Value = 2 And _ Target.Offset(, -1).Value < "" _ And Target.Offset(, -1).Value = 0 Then MsgBox ("You entered " & Target.Value & " After a zero") End If End If End Sub -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "wissam" wrote: Hi. I have a range of cells (C42:M42) where the user can enter values of 0,1,or 2 only (set up via data validation). I need help with a code to do the following: if the worksheet user enters a value or changes the value in a cell in the above range (C42:M42), then excel would automatically check ( via a macro?) the value entered and compare this value to the value present in the previous cell on the same row. If the value entered is 1 or 2, and the value in the previous cell was 0, then it would give a msgbox alert. Any help is appreciated. Thank you very much. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Compare value in current cell to previous cell | Excel Worksheet Functions | |||
Need macro to check if cell is not blank & previous cell is blank, copy information from row above & paste | Excel Programming | |||
Check box, then add current time to cell | Excel Worksheet Functions | |||
formula, move to previous cell when the current cell=0 or empty | Excel Discussion (Misc queries) | |||
How do i check if the current cell is part of a range ? | Excel Programming |