G'day people,
I was hoping that I would be able to gain some guidance on the following issue I have been attempting to resolve,
Currently I am working on an excel document that incorporates multiple functions and sub procedures, it involves taking an array of data, applying data verifcation tests then once passed applying the necessary modifications to the data as set by the user, it follows the proceding basic framework
sub mysub()
dim testbool as boolean
'The Data is sourced from a defined range, say 'Data'
testbool = Data_Verify(Data)
if testbool = true then
'go ahead with modifications
else
'abort and re-enter data
end if
end sub
Unfortunately there is alot of data verification tests that need to be performed, which may only be a slight modification, ie non-empty field etc. At this point the function Data_Verify(Data) has the following framework
function Data_Verify(Data)
'perform test 1
if 'test1 fail' then
Data_verify = false
exit function
end if
'perform test 2
" "
" "
and so on
end function
Obviously as it performs each test if it finds a failed test the function is exited and then the sub. I was hoping that it may be possible to pause the running of the code on an error, allow the user to make a modification and then resume the code.
ie
function Data_Verify(Data)
On Error GoTo Errorcheck
'perform test one
if test is failed then
Error 5000 ' create my own error value
end if
'perform test 2
if test is failed then
Error 5001 ' create another error value
end if
'and so on
'create error check
Errorcheck :
select case err.number
case err.number = 5000
'here is where I was hoping I would be able to enter some code to
stop running the program(or should I say pause the program), alert the user what needs to be changed via a msgbox and allow the user to change the value in the spreadsheet then possibly hit a commandbutton I keep invisible until the error occurs to signify that a change has occured and then resume the code at the next line.
resume next
case err.number = 5001
'and so on
end select
I apologise if I havent worded (and or structured) the question in the appropriate manner, unfortunately I do not possess any formal training in excel vba.
Any help would be greatly appreciated,
David
Bookmarks