VBA code stops in the middle of a for-next loop through a table. What could be going on?

VBA code stops in the middle of a for-next loop through a table

We have an Excel file that loops through a table and based on certain parameters, changes something in a record (row). This looping is in a VBA subroutine, that is part of a bigger subroutine that is triggered through the task scheduler.
We’ve encountered a few times now that the execution stops somewhere in the middle of the loop (we now have an elaborate logging system). And when the task is started again within 5 minutes, it runs smoothly. Which makes me think that it’s not necessarily the Excel file that has a problem, but maybe something with the machine that it’s running on?

The problem is also that the file will stay open and potentially is in the way of other tasks that are scheduled after it. We do use a kill-excel command before most tasks, but that can lead to Excel asking to Recover files and wanting an answer (that the task scheduler can’t give).

What could be going on? What questions do I have to ask to what specialists to solve this issue?

Edit: clarification on the task-scheduler part.
1. the scheduler is time triggered (00:45)
2. it executes a bat-file that in essence first kills existing instances of Excel and Outlook, then opens the Excel that’s one of the parameters and runs a subroutine that is also one of the parameters

This subroutine consists of a few steps
3. determine if it’s a bank holiday (updating a power query to an calendar in another file) – exit sub if yes
4. load prices (updating a power query to the prices file)
5. determine if all prices that are needed are actually there (excel formula) – exit sub if not
6. based on the new prices and information that is in each record already there is a helper column that is either true of false, this subroutine loops through the whole database and where the helper column is true, it changes some of the existing values. And in this subroutine the execution stops, sometimes after 10 true’s, or 5 or 20. And when there are no true’s, it goes onto the next subroutine
7-8-9-10. again a loop through the whole database now with 4 other helper columns.
So far, when the 6th step was done, it got through to the end (= sending out internal e-mails).

A few time I’ve watched it going ‘live’ – and stopping ‘live’ too (cmd window still open, excel open, unresponsive). After killing it all, I just ran the task again, without changing anything, and it would go smoothly.
That’s why I suspect it’s maybe something happening on the machine that halts all this?

I can’t share the file or the VBA code, not even with dummy data, as it would reveal our business formula’s.

Could the syncing of SharePoint/OneDrive be in the way? But if so, why not every day but seemingly random?

New contributor

SledgeNL is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật