Rory, the form (Userform_Test) must be updated if there is a change (add new values, delete or change existing ones...) in the data base worksheet.
My approach was to completely remove the form and create a new one when a change occurs, in that way I avoid keeping track of the kind of change: a new line added, an existing line removed, a modification in an existing line...
I just get rid of the complete form an create a new one from scratch.
Following your advice, I've tried to avoid removing the form. However I still need to remove CommandButtons as the buttons have to be updated according to the change in the data base...
I get an execution time error when I attempt to remove the CommandButtons.
Dim VBComp As Object, VBComps As Object, ctl As Control
Set VBComps = ThisWorkbook.VBProject.VBComponents
For Each VBComp In VBComps
If VBComp.Type = 3 And VBComp.Name = "UserForm_Test" Then
For Each ctl In VBComp.Designer.Controls
VBComp.Designer.Controls.Remove ctl.Name
Next ctl
VBComp.CodeModule.DeleteLines 1, VBComp.CodeModule.CountOfLines
End If
Next VBComp
Find attached Excel sheet.
Any hint to tackle this issue?
Thanks!
Bookmarks