Do While/ Loop

De Bruce

New Member
Joined
May 23, 2019
Messages
30
Good day all,
I have a command button titled "LOW STOCK" on my userform, I want the back color of this button to switch between yellow and salmon when Cell G3 > 0 (Cell G3 contains number of products below stock minimum limit).
The blinking will prompt the user to click the button inorder to display (via a pop up message box) numbers of products having low stock.
I inserted the code below in Userform_Initialize, but excel freezes up and displays on the title bar "Excel is Not Responding". Please I'll be glad to know where I went wrong, thanks in advance.

Sub Userform_Initialize
Do while sheet1.Cells(3, 7) > 0
btnLowStock.Backcolor = RGB(255, 255, 0)
btnLowStock.Backcolor = RGB(255, 128, 128)
Loop
End Sub
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi there. What you have written will cause the initialize routine to loop endlessly, as the value of cells(3,7) will not change during the execution of this code. There are several solutions around already on this forum and others, here is one: https://www.mrexcel.com/forum/excel-questions/273087-flashing-commandbutton.html

Thanks jmcleary,
However, upon starting up the userform, the command button displays only the second color, but does not display the first. As a result of this there's no blinking. Further suggestion are still welcomed. Thanks.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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