VBA Msgbox in loop.

BMD44

Board Regular
Joined
Sep 25, 2019
Messages
72
Hello All,

I am using IF condition in Excel with a message displayed, but the msg is getting displayed in loop hanging the excel.

Private Sub Worksheet_Change (By Val Target As Range)

If Range ("Status") = "PY"
MsgBoxClick = MsgBox ("Data cannot be submitted".)
End If

End Sub

When the value is PY, it keeps displaying Msg. Even after clicking ok, it keeps displaying msg and I am not able to do any other operation and have to close excel.
Please help me on how can the msg be displayed only once and come out of loop / or go to else condition.

Thanks in advance
 
I have no problem with my code, that's why I need to check it in your book, I can't do any more tests in my test file because it works for me.
If it could be possible for you to prepare a file with the problem and share it in the cloud, so I could review it and try to fix the problem.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,214,940
Messages
6,122,356
Members
449,080
Latest member
Armadillos

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