Combining two subs in one sheet - VBA

Paula03

New Member
Joined
May 22, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello everybody,

I'm new here and also fairly new to Excel VBA.

My problem is that I have two subs 'combined' in one sheet, but only one works.

The first part of the code enables me to select more than one worker in column G from a drop down list and is working just fine atm.

The goal of the second part of code, is that if a cell in column J becomes TRUE (WAHR) that the cell in column G is cleared.
But I just can't seem to make this bit work.

I have found a lot of similar threads across different forums, but none of them had an answer to my specific problem.
So any help is appreciated. :)


The part of the table that the code applies to:
1716373236268.png


The code: (pls ignore my comments in green. they're in German and just for my orientation)
1716373108718.png
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Welcome to the Board!

Typically, your error handling happen at the very bottom, before the "End Sub" line. So I think you may want to flip your second block of code and your error handling.

But that may not actually be your problem. The important question is, how exactly is column J being updated?
If it is a formula, it will not work. "Worksheet_Change" event procedures only work when cells are manually updated.
It does not fire when the value changes due to a formula!
 
Upvote 1
Solution
Welcome to the Board!

Typically, your error handling happen at the very bottom, before the "End Sub" line. So I think you may want to flip your second block of code and your error handling.

But that may not actually be your problem. The important question is, how exactly is column J being updated?
If it is a formula, it will not work. "Worksheet_Change" event procedures only work when cells are manually updated.
It does not fire when the value changes due to a formula!
Hello Joe4,

indeed column J is filled automatically if you enter a time in column I.

I just tried it without the formula and filled J manually and the code worked like a charm.

You just solved weeks of headaches and trial and error with two sentences.

Thanks you so much! :D
 
Upvote 0
You are welcome. Glad I was able to help!

Note: Depending on what the formula is in column I, you want be able to keep formulas in column J.
If an update to column I updates the value in the SAME row of column J, and column I is being manually entered into, just change your code to watch for changes to column I instead of column J.
 
Upvote 1

Forum statistics

Threads
1,223,879
Messages
6,175,150
Members
452,615
Latest member
bogeys2birdies

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