Macro / VBA not working

Excelquestion35

Board Regular
Joined
Nov 29, 2021
Messages
53
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

For the first time I tried creating my own VBA code to assist my worksheet. I had the issue that the cells of dependent drop down lists retained their value while their parent was changed.
I have looked up multiple types of code that seem to solve this question, by using VBA. All methods did not work in the workbook, but should normally resolve my question.
I also tried downloading a prescripted version but even this workbook did not seem to work.

This seems to me that I stumbled upon a new problem, but I'm lost. How can I check whether my Macros are enabledf (I do not have a yellow bar saying macros are disabled) and should work properly? And if the code is working properly?

Thanks in advance
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try running one and see if anything happens.

If you're using events (worksheet change for example) then enter the Stop command just below the Sub line and carry out whatever action should cause the code to fire. If the code is working then it will enter debug mode and have a yellow bar through the Stop command when you switch to the editor.
 
Upvote 0
Hi

excel 2019 try the below.

file
options
trust center
trust center settings
macro settings
 
Upvote 0
Thank you for the replies, I tried out both but it doesn't seem to work.

I made a very simplistic version of what I want.

Column B includes two drop down lists as shown below:

1638210165176.png


This is the code I would like to work with:
1638210229852.png
 
Upvote 0
Have you tried completely closing down excel and restarting it?

It is possible that you had disabled events or rejected the macro warning, closing everything down and starting again should reset things. You need to make sure that you close everything, not just the workbook that is causing the problem.
 
Upvote 0
Thank you! That worked out fine in the simplistic version.

Strangely, the same code doesn't work on the document I want to apply it to.
It is a form with already some macros in it. I added this code to it, but for some reason it does not work on this document.
Any idea what could be wrong with this document?
 
Upvote 0
If you're trying to use worksheet change in conjunction with the form then it is likely that events are being temporarily disabled while the form code executes.

If that is the case then you would need to re-enable events at the correct point for the code to trigger when it is needed, or if the change code is only being used for this one thing then it might be better to incorporate it directly into the button code rather than have multiple procedures tangled together like spaghetti. We would need to see the full code to advise further.
 
Upvote 0
You can't attach a file directly to the forum, we only need the code which you can copy and paste here.

Please click on the </> icon above the reply box and paste your code into the popup window, not directly into the message box. This will ensure that your code is tagged correctly and that the formatting is preserved, otherwise it becomes messy and difficult to read.
 
Upvote 0
Looks like I found out the reason why my code dit not work. If I was clicking first on a Macro button that was already inside the document, then the code works afterwards. Now I only have to find out how I can change the sequence.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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