View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
DaveO DaveO is offline
external usenet poster
 
Posts: 94
Default Save using Macro but test to see if an error appears on spreadshee

You'll need to create a variable to store an error, I'd suggest a Boolean.

--------
Dim blnError as Boolean

blnError = False
--------


Then when your code finds an 'error' add this line straight after

--------
blnError = True
--------

Then at the end of your code, before the save happens, try this

--------
If Not blnError then
{Enter your line of code which saves the data}
Else
MsgBox "Error found, workbook not saved!"
end if
--------

Hope this both makes sense and helps.

HTH.

"jfaz" wrote:

I have tests on spreadsheet to see if data is missing and want to save the
spreadsheet using a macro, but first test to see if there is an error
message. I am only a basic user of macro's and use them through record. I
have found out how to put a message box on screen, but want the box to appear
when there is an error, but to save when there are no errors.