VBA message box code - help needed

PGD15

Board Regular
Joined
Aug 5, 2016
Messages
137
Hi,

i am trying to write some code in VBA that says when a button is click check if cell L49 is populated with the value yes then Cells L52,L55,L58 will each needs to be populated, if they are empty I need a message box to appear, if the Cell L49 doesn't say yes the script can end at that stage.

so something like:
on_click()
if range("L49").value = "yes" then
range("L52").value = "" is true
msgbox "Please enter a value"

then repeat this for them all, i know this doesn't work but just to help make clear what i'm asking :)
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Depending on where the code is being placed in the VBAproject, you may need to put in the worksheet name. Assuming you don't, try this.

Code:
[COLOR=#333333]on_click()[/COLOR]
[COLOR=#333333]if range("L49").value = "yes" and  range("L52").value = "" or range("L55").value = "" or range("L58").value = "" then[/COLOR]
[COLOR=#333333]
msgbox "Please enter a value" 

[/COLOR]end if

alternately, if you need to put the worksheet names in it would look like this:

Code:
[COLOR=#333333]on_click()[/COLOR]
[COLOR=#333333]if [I]worksheets[name].[/I]range("L49").value = "yes" and  [/COLOR][I]worksheets[name].[/I][COLOR=#333333]range("L52").value = "" or [/COLOR][I]worksheets[name].[/I][COLOR=#333333]range("L55").value = "" or [/COLOR][I]worksheets[name].[/I][COLOR=#333333]range("L58").value = "" then[/COLOR]
[COLOR=#333333]
msgbox "Please enter a value" 

[/COLOR]end if
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,384
Members
448,956
Latest member
JPav

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