![]() |
#5
|
|||
|
|||
![]() Quote:
Code:
Sub BeSafe() 'code to try number from 10 - 100 until an unsafe calculation is performed Dim CheckCell As Integer, CheckValue As Integer CheckRow = 10 CheckValue = 10 Do Do Range("aa" & CheckRow).Select Range("aa" & CheckRow).Value = CheckValue CheckValue = CheckValue + 10 Loop While Range("cf" & CheckRow).Value = "Safe" ' Take the value back to safe Range("aa" & CheckRow).Value = CheckValue - 20 ' Check if value is above 100 If Range("aa" & CheckRow).Value > 100 Then Range("aa" & CheckRow).Value = 100 End If CheckRow = CheckRow + 1 CheckValue = 10 Loop Until Range("aa" & CheckRow).Value = "" End Sub I will not force this knowledge upon you but will offer to explain it in a future post if you wish. By the way this code should work for multiple rows if you add more. We can also have the code write the if statement in CF so you dont have to copy down the formulas but this should work for now. Let me know how it works for you. Oh one more thing. I get the feeling you were doing values 1 - 10 in column AA because it was a dropdown list. If you want to make this macro do the same but check with any value from 1 to 100 it is very easy to modify the code to do this and it will run just as fast. Let us know Thanks |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA: How to place dropdown list next to text | YigalB | Word VBA | 0 | 08-11-2013 01:48 PM |
block selection in dropdown list | Intruder | Excel | 2 | 01-10-2013 10:20 AM |
![]() |
r_p_t_0 | Word | 2 | 12-18-2012 05:55 AM |
![]() |
lawlaw | Mail Merge | 3 | 11-29-2012 04:47 PM |
Dropdown list of email addresses | J Partridge | Outlook | 1 | 01-13-2011 06:37 AM |