Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default 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/

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Macro running another macro inside K1KKKA Excel Discussion (Misc queries) 1 December 20th 06 08:21 PM
disable user running macro from Tools Macro Steve Simons Excel Discussion (Misc queries) 4 September 28th 06 06:28 AM
paste into filter criteria box running macro stephan brisson Excel Programming 1 April 17th 04 03:23 AM
running a macro ina workbook that doesnt have that macro Paul Excel Programming 2 February 18th 04 01:47 AM
Launch Macro in Access via Macro running in Excel??? dgrant Excel Programming 1 September 24th 03 01:38 PM


All times are GMT +1. The time now is 05:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"