Calculate worksheet when combobox or textbox data is changed by user

cvrband

Board Regular
Joined
Jan 6, 2016
Messages
63
Office Version
  1. 365
Platform
  1. Windows
I have a worksheet that has many comboboxes (drop-down lists) and many textboxes for user input. The workbook is set to manual calculation but I have the following VBA on this sheet to calculate the sheet on change:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)        
    Worksheets("DATA").Calculate
End Sub
When a new item is selected in one of the many comboboxes or new data is input in any of the textboxes, that code does not seem to recognize a change on the sheet and does not calculate. Can someone help expand that code to recognize combobox or textbox changes to fire the sheet calculate?

Thank you.
 
I added and modified your latest code to test: ComboBox101_Change() and also to 2 of the text boxes: Textbox104_Change(), Textbox105_Change(). I also modified the calculation method to only calculate this sheet so no wait time for total workbook calculation and everything works well for the 3 items that I tested.

Before I expand to all Combo/Text boxes, this worksheet has 9 Combo boxes and 13 Text boxes that would require separate Subs (total of 22 Subs). How will that many short lines of code affect things? Is it simply ugly coding but no other issues?

Thanks for the follow-up.
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
That's a very good choice of words :) apart from "ugly coding" there is no other impact. If you add the same code to all 9 combo boxes and 13 text boxes then each time you modify one of them the whole worksheet will recalculate (exactly how you wanted it to work).
The code that I posted previously will automatically work for all combo boxes / text boxes on a given sheet, so that you wouldn't need to manually assign "Calculate" change event to each one of them and repeat this process for any new objects that will appear in your sheet in the future. However, if you have troubles recreating it in your file and it's easier for you to simply create 9+13 macros, then I agree it will be much faster for you to do that.

Anyway, I'm very glad things are working for you. Take care & good luck with any future challenges!
 
Upvote 0

Forum statistics

Threads
1,215,301
Messages
6,124,142
Members
449,144
Latest member
Rayudo125

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