![]() |
running a macro only if criteria are met
hello all,
I have a macro that runs fine, the problem is it relies on user input and will run even if the data received is invalid. I can calculat simple checks to confirm if the user has inputted valid data, an simply set a test cell to either "YES" or "NO". Is there any way I can amend the macro such that if the cell reads "NO the macro stops and gives the user a relevant message, and if the cel reads "YES", the macro runs through as normal. any help/comments will be appreciated. CHEER -- Message posted from http://www.ExcelForum.com |
running a macro only if criteria are met
Try something like this, although you could just use the
test criteria in the IF statement, rather than checking a cell value. If Sheets("Sheet 1").Range("A1").Value = "No" Then MsgBox(Invalid data Input.") Exit Sub End If Cheers, Pete. -----Original Message----- hello all, I have a macro that runs fine, the problem is it relies on user input, and will run even if the data received is invalid. I can calculate simple checks to confirm if the user has inputted valid data, and simply set a test cell to either "YES" or "NO". Is there any way I can amend the macro such that if the cell reads "NO" the macro stops and gives the user a relevant message, and if the cell reads "YES", the macro runs through as normal. any help/comments will be appreciated. CHEERS --- Message posted from http://www.ExcelForum.com/ . |
All times are GMT +1. The time now is 06:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com