VBA if specific pop up then close

dshafique

Board Regular
Joined
Jun 19, 2017
Messages
171
Hi everyone, i am working on a macro which populates an input table for BEX analyzer add in. I am using sendkeys method and there is a popup that comes up if the input is wrong.

is there a way for me to make an if statement depending on the title of the alert.
for example:
If popup title = "BEX analyzer"
then send key {Enter}
Send key {enter}
Else
move on
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
VBA Code:
If popup title = "BEX analyzer" Then
    send key {Enter}
    Send key {enter}
Else
    Exit Sub
end if

or ...

If popup title = "BEX analyzer" Then
    send key {Enter}
    Send key {enter}
Else
    Call TheNameOfTheSubYouWantToGoTo
end if
 
Upvote 0
VBA Code:
If popup title = "BEX analyzer" Then
    send key {Enter}
    Send key {enter}
Else
    Exit Sub
end if

or ...

If popup title = "BEX analyzer" Then
    send key {Enter}
    Send key {enter}
Else
    Call TheNameOfTheSubYouWantToGoTo
end if
Thank you, when I type any of these in, it gives me an error in the "title" part. is there a library I need?
 
Upvote 0
I am not familiar.

What specifically is : popup title ?

Please describe.
 
Upvote 0
I am not familiar.

What specifically is : popup title ?

Please describe.
ah, i see. popup title is not a variable. I wanted to know how to perform an action based off what the title of the alert is. for example, if the popup's title bar says "Bex Analyzer" I want the macro to activate the alert box and press "Tab" and "Enter"

if anything else, i want the macro to activate the window and press tab twice and then enter (which will exit out of it)
 
Upvote 0
Is the "popup title" the title viewed on a MsgBox notification ?

Or is the "title" belonging to some other piece of software (not Excel) ?
 
Upvote 0
While a MsgBox is visible, you can press keys CTRL / C. That copies the contents of a MsgBox. You can then press keys CTRL / V. That will paste
what has been copied to the active cell. Practice.

Now, you can write a macro to perform the COPY / PASTE routines. Then, you will need to add code that identifies the second row that was pasted.
The first row will be only dashes.
 
Upvote 0

Forum statistics

Threads
1,223,959
Messages
6,175,649
Members
452,663
Latest member
MEMEH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top