954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to pragramaticaly "OK" a messagebox?

I have this litle problem:
I have inserted a lot of data into a excel form. After that I wish to do a bit of sorting and all that stuf before I actually create a chart. So I used the subtotal routine.
Somehow this routine ignores my first row of data. Very well, I'll let it start at one row higher. But excel drops a messagebox to tell me this row doesn't contain any data. (hey tell me) and I have to push the "OK"button to continu.
I wonder, is there a method to programaticaly push the "OK" button so my litle program can continu without me sitting on the watch?

The code looks like this:

oRng = oSheet.Range("F4", "F" & einde + 4 & "")
        oRng.Select()
        oRng.Copy()

        PRang = oSheet.Range("AA4", "AA" & einde + 4 & "")
        PRang.PasteSpecial()

        oRng = oSheet.Range("I4", "I" & einde + 4 & "")
        oRng.Select()
        oRng.Copy()

        PRang = oSheet.Range("AB4", "AB" & einde + 4 & "")
        PRang.PasteSpecial()

        oRng = oSheet.Range("AA3", "AB" & einde + 4 & "")
        oRng.Select()
        oRng.Subtotal(1, Excel.XlConsolidationFunction.xlSum, 2, True, False, True)


Anyway, thanks in advance.

Eekhoorn
Newbie Poster
17 posts since Oct 2010
Reputation Points: 10
Solved Threads: 2
 

You could try putting the code in a try catch, and have the program run the code if it finds an exception. It will find said exception, then should just run the code. u should not need to worry about if it does not find the exception, as it will. if for some reasons the gremlins go away and it does not create an exception, put the code u have written here in a call statement, and have a call statement to that statement in both instances. Its not pretty, but should work.

manshipboy
Newbie Poster
8 posts since Nov 2010
Reputation Points: 10
Solved Threads: 1
 

Thanx a lot for the help. Unluckily the try catch didn't do anything, but even worse is the fact that i didn't read the message excel threw too well. Because when I puted some labels on top of my rows, as excel sugested, the messagebox went away and my code runs fluently :S

Me.stupid = true
Eekhoorn
Newbie Poster
17 posts since Oct 2010
Reputation Points: 10
Solved Threads: 2
 

i ask before about it and no one help even in MSDN forum

but you can try to make anew form as message box and use timer to close it after some time

el3ashe2
Newbie Poster
8 posts since Dec 2007
Reputation Points: 8
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You