![]() |
stop a macro if it does not contain
I have a macro that i would like to NOT to run (or stop) if it does
not contain the word "wildman" in a range A2:A30000 or if there is no text in that range as well. Thanks in advance Wildman |
stop a macro if it does not contain
Private Sub CommandButton1_Click() If WorksheetFunction.CountIf(Range("A2:A30"), "wildman") < 1 Then Exit Sub End If ' continue your code here End Sub No need to check if range empty as if "wildman" not there then no need to run macro. I have a macro that i would like to NOT to run (or stop) if it does not contain the word "wildman" in a range A2:A30000 or if there is no text in that range as well. Mangesh -- mangesh_yadav ------------------------------------------------------------------------ mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470 View this thread: http://www.excelforum.com/showthread...hreadid=375134 |
stop a macro if it does not contain
nv test it out but shld be correct Code: -------------------- sub macro() For each rngCell in activesheet.range(A2:A30000).cells if rngCell.value="wildman" then blnWildman=true blnNotEmpty=true exit for elseif rngCell<empty then blnNotEmpty=true exit for end if next rngCell if blnWildman<true and blnNotEmpty<true then Exit sub end if <macro code End Sub -------------------- -- d61helix ------------------------------------------------------------------------ d61helix's Profile: http://www.excelforum.com/member.php...o&userid=20090 View this thread: http://www.excelforum.com/showthread...hreadid=375134 |
stop a macro if it does not contain
OK, am I the only one wondering why the heck you're looking for a
wildman? |
stop a macro if it does not contain
No you are not the only one.
"Nick Hebb" wrote in message ups.com... OK, am I the only one wondering why the heck you're looking for a wildman? |
All times are GMT +1. The time now is 01:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com