I have run across some strange behavior, and am wondering if anyone else has experienced this.
I have a worksheet where the user can import pictures via VBA code. I also have a couple of checkboxes (form controls) on that sheet.
I have a button that allows the user to clear the sheet of all data, including the pictures. What is strange is that I have found that when running the code to clear the sheet, sometimes the code will delete one or both of the checkboxes. Sometimes it deletes one of them, sometimes it deletes both of them, and sometimes it doesn't delete either of them. But the code is the SAME each time I test it, so why it is so inconsistent makes no sense to me.
I have stepped through the code and found the line where it is sometimes deleting the checkboxes.
I wouldn't think that checkboxes would be considered pictures, which is why am using this code rather than .Shapes.Delete.
Does anyone have any suggestions of what I might try to stop this problem from happening? Or even better, does anyone know why this could be happening at all?
BTW, I am running Windows 10 (64-bit) with Excel 365 (32-bit).
I have a worksheet where the user can import pictures via VBA code. I also have a couple of checkboxes (form controls) on that sheet.
I have a button that allows the user to clear the sheet of all data, including the pictures. What is strange is that I have found that when running the code to clear the sheet, sometimes the code will delete one or both of the checkboxes. Sometimes it deletes one of them, sometimes it deletes both of them, and sometimes it doesn't delete either of them. But the code is the SAME each time I test it, so why it is so inconsistent makes no sense to me.
I have stepped through the code and found the line where it is sometimes deleting the checkboxes.
Code:
ThisWorkbook.Sheets("Sheet1").Pictures.Delete
I wouldn't think that checkboxes would be considered pictures, which is why am using this code rather than .Shapes.Delete.
Does anyone have any suggestions of what I might try to stop this problem from happening? Or even better, does anyone know why this could be happening at all?
BTW, I am running Windows 10 (64-bit) with Excel 365 (32-bit).
Last edited: