Is there is way to know if the user changed a cells value in excel and python can react to it?
Asked
Active
Viewed 144 times
1 Answers
0
You can use the xlwings library.
The code can be difference, but there is a code from one of my projects:
import xlwings as xw
wb = xw.Book.active()
sheet = wb.sheets['Sheet1']
range_to_monitor = sheet.range('A1')
previous_value = range_to_monitor.value
while True:
current_value = range_to_monitor.value
if current_value != previous_value:
print(f"Value changed from {previous_value} to {current_value}")
previous_value = current_value
else:
xw.apps.active.api.Sleep(100)

Dmitrii Malygin
- 144
- 2
- 2
- 12
-
this code works but will it be efficient? Is there any other way such as registering to callback when value in cell changes? – Awdsa Mar 23 '23 at 12:57