VBA Macro Help

remusbv8

New Member
Joined
Jan 10, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,

I am trying to build a macro that will stop me to add values to a specific row in a column is a condition is met.

What I have is a Holiday plan with a %10 quota per day separated by column and rows. Basically when D4 reached 10% I want the code to tell me to stop adding in that column because the quota was met but it should allow me to add in other columns where the the quota is still not met.See picture below.

1698064903680.png
I managed to make a code but when the quota is met it doesn't allow me anymore to click anything.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Range("A1:C24").Find(what:="Limit Reached", LookIn:=xlValues, lookat:=xlWhole, MatchCase:=True) Is Nothing Then

MsgBox "Stop adding"

End If

End Sub

Any help would be much appreciated.

Thanks.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I would do this with a custom data validation rule instead of VBA.

Excel Formula:
=D$4<10%

Looks like D3 in your screenshot but I wrote the formula based on your description.

You can then copy this and Paste Special > Validation to any cell in any column where you need this.
 
Upvote 0
I would do this with a custom data validation rule instead of VBA.

Excel Formula:
=D$4<10%

Looks like D3 in your screenshot but I wrote the formula based on your description.

You can then copy this and Paste Special > Validation to any cell in any column where you need this.
Hey hey.

I tried what you said but it doesn't do anything.

 

Attachments

  • 1698132120886.png
    1698132120886.png
    44.8 KB · Views: 5
Upvote 0
Also please note that for me in D3 and etc I have a formula that calculated my %
 
Upvote 0
I said that your description referred to cell D4 but your screenshot looks like cell D3 (even though you did not show row numbers), so I wrote the formula for D4. If the % is in cell D3 then the formula must refer to D3.

In the most recent images you attached, I do not know what cell that formula is in and I don't know what cell(s) you applied that data validation rule to. However, it seems to be the same cell and there is no point in putting data validation into a cell that has a formula. The data validation rule should be applied to cells where the user is expected to enter data.
 
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