Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have the following in a spreadsheet: I J 1 1.0 1.0 2 2.0 0.3 3 1.0 4 1.2 5 2.3 2.3 I would like to be able to put some code behind that loops through the above range checks to see if for example the sum of I1:J1 is equal or greater than 2 and then throw up a msgbox otherwise do nothing. Is this possible? normally i would keep working at it but the project i am on is due by end of today so thankyou all in advance for any help you can provide. 8-) Tanya |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tanya, the first Sub below will do as you have requested, although you may
not want to have to respond to all the messages, but .... The second routine will not nag you with messages, but will color the cell pair involved red to point them out instead. Sub LotsOfMessages() Dim lastRow As Long Dim lCounter As Long Dim baseCell As Range Set baseCell = Range("A1") lastRow = baseCell.End(xlDown).Row - 1 For lCounter = 0 To lastRow If baseCell.Offset(lCounter, 0) + _ baseCell.Offset(lCounter, 1) 2 Then MsgBox "Row " & lCounter + 1 & " is 2" End If Next End Sub Sub ColorMarkThem() Dim lastRow As Long Dim lCounter As Long Dim baseCell As Range Set baseCell = Range("A1") lastRow = baseCell.End(xlDown).Row - 1 For lCounter = 0 To lastRow baseCell.Offset(lCounter, 0).Interior.ColorIndex = _ xlNone ' clear any prior coloring baseCell.Offset(lCounter, 1).Interior.ColorIndex = _ xlNone ' clear any prior coloring If baseCell.Offset(lCounter, 0) + _ baseCell.Offset(lCounter, 1) 2 Then baseCell.Offset(lCounter, 0).Interior.ColorIndex = 3 baseCell.Offset(lCounter, 1).Interior.ColorIndex = 3 End If Next End Sub "Tanya" wrote: Hi, I have the following in a spreadsheet: I J 1 1.0 1.0 2 2.0 0.3 3 1.0 4 1.2 5 2.3 2.3 I would like to be able to put some code behind that loops through the above range checks to see if for example the sum of I1:J1 is equal or greater than 2 and then throw up a msgbox otherwise do nothing. Is this possible? normally i would keep working at it but the project i am on is due by end of today so thankyou all in advance for any help you can provide. 8-) Tanya |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
checking two different cells | Excel Worksheet Functions | |||
Checking cells contain a value | Excel Programming | |||
Checking range of cells for entry then checking for total | Excel Programming | |||
Checking the Cells in Sheet1 with Cells in Sheet2 and replace | Excel Worksheet Functions | |||
copying cells by checking color of the cells | Excel Programming |